Browse Source

Added score, small changes

master
Unbewohnte 4 years ago
parent
commit
3303781ae4
  1. 20
      Main.py
  2. 8
      beings.py
  3. 4
      particles.py

20
Main.py

@ -15,7 +15,7 @@ icon = pygame.image.load('pics/logo.png')
pygame.display.set_icon(icon)
font = pygame.font.Font('freesansbold.ttf', 46)
########
DEBUG = False
################################################################
def play():
FPS = 70
@ -25,6 +25,7 @@ def play():
enemy2 = Enemy(windowX,200)
player = Player()
death_timer = 70
SCORE = 0
##########################
while True:
for event in pygame.event.get():
@ -35,6 +36,14 @@ def play():
window.fill((41, 64, 59))
pygame.draw.rect(window,(0,0,0),(0,720,windowX,5))
if DEBUG == True:
for row in range(0,windowX,32):
pygame.draw.rect(window,(184, 227, 179, 1),(row,0,2,windowY))
for column in range(0,windowY,64):
pygame.draw.rect(window,(184, 227, 179),(0,column,windowX,2))
##########################
#PPPPPPPPPPPPPPPPPPPPPPPPP
@ -72,16 +81,21 @@ def play():
if enemy2.enemy_x <= 5: #That returning thingy
enemy2.enemy_x = windowX
if enemy.out_of_area() or enemy.enemy_y + enemy.en_height >= 720:
if enemy.out_of_area() and enemy.alive == True or enemy.enemy_y + enemy.en_height >= 720 and enemy.alive == True:
enemy.alive = False
if enemy2.out_of_area() or enemy2.enemy_y + enemy2.en_height >= 720:
SCORE += 1
if enemy2.out_of_area() and enemy2.alive == True or enemy2.enemy_y + enemy2.en_height >= 720 and enemy2.alive == True:
enemy2.alive = False
SCORE += 1
if enemy.alive == False and enemy2.alive == False:
print('Win-win')
break
#EEEEEEEEEEEEEEEEEEEEEEEEE
score_font = font.render(str(SCORE), True, (114, 150, 47))
window.blit(score_font,(100,100))
clock.tick(FPS)
pygame.display.update()
pass

8
beings.py

@ -94,8 +94,8 @@ class Player:
def collision(self,window):
for bullet in enemy_bul_on_screen:
if self.player_rect.colliderect(bullet.bullet_rect):
self.x += randint(-100,100)
self.y += randint(-100,100)
self.x += randint(-100*1.4,100*1.4)
self.y += randint(-100*1.4,100*1.4)
enemy_bul_on_screen.remove(bullet)
for i in range(5):
particle = Particle(self.player_rect[0] + self.width/2, self.player_rect[1] + self.height)
@ -158,8 +158,8 @@ class Enemy:
for bullet in player_bullets_on_screen:
if self.enemy_rect.colliderect(bullet.bullet_rect):
player_bullets_on_screen.remove(bullet)
self.enemy_x += randint(-100,100)
self.enemy_y += randint(-100,100)
self.enemy_x += randint(-100*1.4,100*1.4)
self.enemy_y += randint(-100*1.4,100*1.4)
for i in range(5):
particle = Particle(self.enemy_rect[0] + self.en_width/2, self.enemy_rect[1] + self.en_height)
particles_on_screen_e.append(particle)

4
particles.py

@ -7,13 +7,13 @@ class Particle:
def __init__(self,x,y):
self.x = x
self.y = y
self.width = 4 #4
self.width = 4
self.height = self.width
self.vel = int(randint(0,3)/5)
self.rect = pygame.Rect(self.x,self.y,self.width,self.height)
self.timer = randint(10,66)
def draw(self,window):
for i in range(5): #5
for i in range(5):
pygame.draw.rect(window,(randint(200,255),randint(50,255),20),(self.rect[0] + randint(-35,35), self.rect[1] + randint(-30,30), self.rect[2], self.rect[3]))
def update(self,side):
if str(side) == "up":

Loading…
Cancel
Save