From 3303781ae4724148be4166a1dceb9a94935bfb65 Mon Sep 17 00:00:00 2001 From: Unbewohnte Date: Wed, 19 Aug 2020 11:39:15 +0300 Subject: [PATCH] Added score, small changes --- Main.py | 20 +++++++++++++++++--- beings.py | 8 ++++---- particles.py | 4 ++-- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Main.py b/Main.py index 5046559..a74a139 100644 --- a/Main.py +++ b/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 diff --git a/beings.py b/beings.py index 6ceb857..8b8a386 100644 --- a/beings.py +++ b/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) diff --git a/particles.py b/particles.py index 2bb9fb2..4a0704f 100644 --- a/particles.py +++ b/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":