Browse Source

Enemy now shoots

master
Unbewohnte 4 years ago
parent
commit
5ba04e00f5
  1. 3
      Main.py
  2. 2
      bullets.py
  3. 12
      enemy.py

3
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)

2
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

12
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:

Loading…
Cancel
Save