Browse Source

Created another enemy and expanded logic in mainloop

master
Unbewohnte 4 years ago
parent
commit
c5a6d21ba5
  1. 33
      Main.py
  2. 11
      beings.py
  3. 1
      particles.py

33
Main.py

@ -21,7 +21,8 @@ def play():
FPS = 70
clock = pygame.time.Clock()
pygame.mouse.set_visible(False)
enemy = Enemy()
enemy = Enemy(100,100)
enemy2 = Enemy(windowX,200)
player = Player()
death_timer = 70
##########################
@ -33,6 +34,7 @@ def play():
break
window.fill((41, 64, 59))
pygame.draw.rect(window,(0,0,0),(0,720,windowX,5))
##########################
#PPPPPPPPPPPPPPPPPPPPPPPPP
@ -54,16 +56,29 @@ def play():
#PPPPPPPPPPPPPPPPPPPPPPPPP
#EEEEEEEEEEEEEEEEEEEEEEEEE
enemy.enemy_shoot(window)
enemy.draw(window)
enemy.move('right')
if enemy.alive == True:
enemy.enemy_shoot(window)
enemy.draw(window)
enemy.move('right')
enemy.collision(window)
if enemy.enemy_x >= windowX-10: #That returning thingy
enemy.enemy_x = 5
if enemy.enemy_x >= windowX-10: #That returning thingy
enemy.enemy_x = 5
enemy.collision(window)
if enemy2.alive == True:
enemy2.enemy_shoot(window)
enemy2.move('left')
enemy2.draw(window)
enemy2.collision(window)
if enemy2.enemy_x <= 5: #That returning thingy
enemy2.enemy_x = windowX
if enemy.out_of_area():
print('Random is on our side')
if enemy.out_of_area() or enemy.enemy_y + enemy.en_height >= 720:
enemy.alive = False
if enemy2.out_of_area() or enemy2.enemy_y + enemy2.en_height >= 720:
enemy2.alive = False
if enemy.alive == False and enemy2.alive == False:
print('Win-win')
break
#EEEEEEEEEEEEEEEEEEEEEEEEE

11
beings.py

@ -109,13 +109,14 @@ class Player:
class Enemy:
def __init__(self):
self.enemy_x = 100
self.enemy_y = 100
def __init__(self,x,y):
self.enemy_x = x #100
self.enemy_y = y #100
self.en_width = 32
self.en_height = 64
self.vel = 3
self.bul_cooldown = 10
self.alive = True
def draw(self,window):
pygame.draw.rect(window,(0,0,0),(self.enemy_x, self.enemy_y, self.en_width, self.en_height))
window.blit(enemy_image,(self.enemy_x, self.enemy_y))
@ -157,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(-60,60)
self.enemy_y += randint(-60,60)
self.enemy_x += randint(-100,100)
self.enemy_y += randint(-100,100)
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)

1
particles.py

@ -19,7 +19,6 @@ class Particle:
if str(side) == "up":
for particle in particles_on_screen_e:
particle.timer -= 0.5
#self.rect[1] -= (self.vel - randrange(-7,1))
particle.rect[1] += (self.vel + randrange(-7,1))
particle.rect[0] += (self.vel + randrange(-3,3))
if particle.timer <= 0:

Loading…
Cancel
Save