Browse Source

Trying to fix a bug

master
Unbewohnte 4 years ago
parent
commit
b888abfcd2
  1. 25
      Main.py
  2. 5
      beings.py
  3. 2
      surfaces.py

25
Main.py

@ -20,10 +20,13 @@ def play():
pygame.mouse.set_visible(False) pygame.mouse.set_visible(False)
slowsurf = SlowTimeSurf(384,64) slowsurf = SlowTimeSurf(384,64)
enemy = Enemy(100,100) enemy = Enemy(100,100)
#enemies_on_screen.append(enemy)
enemy2 = Enemy(windowX,200) enemy2 = Enemy(windowX,200)
#enemies_on_screen.append(enemy2)
player = Player() player = Player()
death_timer = 70 death_timer = 70
SCORE = 0 SCORE = 0
ppp = False
########################## LAYER 0 ########################## LAYER 0
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
@ -50,15 +53,16 @@ def play():
print("Colliding !") print("Colliding !")
slowsurf.switch = False slowsurf.switch = False
else: else:
if slowsurf.timer >= 0: if slowsurf.activation_timer >= 0:
slowsurf.timer -= 1 slowsurf.activation_timer -= 1
enemy.vel = 3 - 2 enemy.vel = 3 - 2
enemy2.vel = 3 - 2 enemy2.vel = 3 - 2
enemy.bul_cooldown += 1.5 enemy.bul_cooldown += 1.5
enemy2.bul_cooldown += 1.5 enemy2.bul_cooldown += 1.5
else: else:
enemy.vel = 3 enemy.refresh()
enemy2.vel = 3 enemy2.refresh()
player.teleportation() player.teleportation()
player.shoot(window) player.shoot(window)
@ -81,17 +85,17 @@ def play():
########################## LAYER 2 ########################## LAYER 2
if enemy.alive == True: if enemy.alive == True:
enemy.enemy_shoot(window)
enemy.draw(window) enemy.draw(window)
enemy.move('right') enemy.move('right')
enemy.enemy_shoot(window)
enemy.collision(window) enemy.collision(window)
if enemy.enemy_x >= windowX-10: #That returning thingy if enemy.enemy_x >= windowX-10: #That returning thingy
enemy.enemy_x = 5 enemy.enemy_x = 5
if enemy2.alive == True: if enemy2.alive == True:
enemy2.draw(window)
enemy2.enemy_shoot(window) enemy2.enemy_shoot(window)
enemy2.move('left') enemy2.move('left')
enemy2.draw(window)
enemy2.collision(window) enemy2.collision(window)
if enemy2.enemy_x <= 5: #That returning thingy if enemy2.enemy_x <= 5: #That returning thingy
enemy2.enemy_x = windowX enemy2.enemy_x = windowX
@ -106,6 +110,15 @@ def play():
if enemy.alive == False and enemy2.alive == False: if enemy.alive == False and enemy2.alive == False:
print('Win-win') print('Win-win')
break break
# for enemy in enemies_on_screen:
# if enemy[0].alive == True:
# enemy[0].move('right')
# enemy[0].enemy_shoot(window)
# enemy[0].draw(window)
# enemy[0].collision(window)
# else:
# enemy[0].draw(window)
########################## LAYER 2 END ########################## LAYER 2 END
########################## LAYER 3 ########################## LAYER 3

5
beings.py

@ -7,7 +7,7 @@ from settings import windowX,windowY,bullet_image,enemy_bul_img,enemy_image,play
import time import time
import sys import sys
enemies_on_screen = []
class Player: class Player:
def __init__(self): def __init__(self):
@ -163,3 +163,6 @@ class Enemy:
for particle in particles_on_screen_e: for particle in particles_on_screen_e:
particle.draw(window) particle.draw(window)
particle.update("up") particle.update("up")
def refresh(self):
#self.bul_cooldown = 10
self.vel = 3

2
surfaces.py

@ -22,7 +22,7 @@ class SlowTimeSurf:
self.color = (0,0,0) self.color = (0,0,0)
self.rect = pygame.Rect(self.x, self.y, self.width, self.height) self.rect = pygame.Rect(self.x, self.y, self.width, self.height)
self.switch = True self.switch = True
self.timer = 500 self.activation_timer = 500
def place(self,window): def place(self,window):
pygame.draw.rect(window,self.color,self.rect) pygame.draw.rect(window,self.color,self.rect)
window.blit(timesurf_image,(self.rect[0], self.rect[1])) window.blit(timesurf_image,(self.rect[0], self.rect[1]))

Loading…
Cancel
Save