diff --git a/Main.py b/Main.py index 0b7b665..7b64fe0 100644 --- a/Main.py +++ b/Main.py @@ -19,6 +19,7 @@ pygame.display.set_icon(icon) bullet_image = pygame.image.load('pics/second_bullet.png') +enemy_bul_img = pygame.image.load('pics/bullet.png') enemy_image = pygame.image.load('pics/32x64.png') player_image = pygame.image.load('pics/32x64.png') ######## @@ -49,6 +50,8 @@ def play(): player.draw(window,start_color,player_image) player.update(window,start_color,bullet_image) + + enemy.enemy_shoot(window,start_color,enemy_bul_img) enemy.draw(window,start_color,enemy_image) enemy.update() enemy.collision(enemy) diff --git a/bullets.py b/bullets.py index 8c98a78..8d55cb1 100644 --- a/bullets.py +++ b/bullets.py @@ -13,3 +13,5 @@ class Bullet: window.blit(bullet_image,(self.bullet_x, self.bullet_y)) def move(self): self.bullet_y -= self.bullet_vel + def moveb(self): + self.bullet_y += self.bullet_vel diff --git a/enemy.py b/enemy.py index 05aef49..15ac63e 100644 --- a/enemy.py +++ b/enemy.py @@ -5,6 +5,7 @@ from random import randint windowX = 640 windowY = 640 +enemy_bul_on_screen = [] class Enemy: def __init__(self): @@ -20,8 +21,15 @@ class Enemy: self.enemy_x += 3 if self.enemy_x >= 600: self.enemy_x = 1 - def enemy_shoot(self): #Have NO IDEA how it`ll work - pass + def enemy_shoot(self,window,start_color,bul_image): #Have NO IDEA how it`ll work + new_bullet = Bullet(self.enemy_x + self.en_width/2, self.enemy_y + 10) + enemy_bul_on_screen.append(new_bullet) + if int(len(enemy_bul_on_screen)) > 0: + for bullet in enemy_bul_on_screen: + bullet.draw(window,start_color,bul_image) + bullet.moveb() + if bullet.bullet_y >= windowY +20: + enemy_bul_on_screen.remove(bullet) def out_of_area(self): if self.enemy_x > windowX or self.enemy_x < 0 or self.enemy_y > windowY or self.enemy_y < 0: