Browse Source

Bug is no more; SlowTimeSurf is better now

master
Unbewohnte 4 years ago
parent
commit
be2d5703c9
  1. 19
      Main.py
  2. 4
      beings.py
  3. 22
      surfaces.py

19
Main.py

@ -20,13 +20,13 @@ def play():
pygame.mouse.set_visible(False)
slowsurf = SlowTimeSurf(384,64)
enemy = Enemy(100,100)
#enemies_on_screen.append(enemy)
enemy2 = Enemy(windowX,200)
#enemies_on_screen.append(enemy2)
enemies_on_screen.append(enemy)
enemies_on_screen.append(enemy2)
print(enemies_on_screen)
player = Player()
death_timer = 70
SCORE = 0
ppp = False
########################## LAYER 0
while True:
for event in pygame.event.get():
@ -53,15 +53,10 @@ def play():
print("Colliding !")
slowsurf.switch = False
else:
if slowsurf.activation_timer >= 0:
slowsurf.activation_timer -= 1
enemy.vel = 3 - 2
enemy2.vel = 3 - 2
enemy.bul_cooldown += 1.5
enemy2.bul_cooldown += 1.5
else:
enemy.refresh()
enemy2.refresh()
#for enemy in enemies_on_screen:
slowsurf.activate(enemy)
slowsurf.activate(enemy2)
player.teleportation()

4
beings.py

@ -108,7 +108,7 @@ class Enemy:
self.en_width = 32
self.en_height = 64
self.vel = 3
self.bul_cooldown = 10
self.bul_cooldown = 20 #12
self.alive = True
self.enemy_rect = pygame.Rect(self.enemy_x, self.enemy_y, self.en_width, self.en_height)
@ -127,7 +127,7 @@ class Enemy:
self.enemy_y += self.vel
def enemy_shoot(self,window):
if self.bul_cooldown >= 1:
self.bul_cooldown -= 2
self.bul_cooldown -= 2 # -=2
if self.bul_cooldown <= 0:
new_bullet = Bullet(self.enemy_x + self.en_width/2, self.enemy_y + 10)

22
surfaces.py

@ -1,8 +1,8 @@
import pygame
from beings import *
#from beings import *
from settings import timesurf_image
class Surface:
class BuffRandomSurf:
def __init__(self,surf_x,surf_y):
self.x = surf_x
self.y = surf_y
@ -12,6 +12,11 @@ class Surface:
self.rect = pygame.Rect(self.x,self.y,self.width,self.height,)
def place(self,window,surf_x,surf_y):
pygame.draw.rect(window,self.color,self.rect)
def collide(self,object):
if self.rect.colliderect(object):
return True
else:
return False
class SlowTimeSurf:
def __init__(self,surf_x,surf_y):
@ -22,7 +27,7 @@ class SlowTimeSurf:
self.color = (0,0,0)
self.rect = pygame.Rect(self.x, self.y, self.width, self.height)
self.switch = True
self.activation_timer = 500
self.activation_timer = 1000
def place(self,window):
pygame.draw.rect(window,self.color,self.rect)
window.blit(timesurf_image,(self.rect[0], self.rect[1]))
@ -31,3 +36,14 @@ class SlowTimeSurf:
return True
else:
return False
def activate(self,enemy):
if self.activation_timer > 0:
self.activation_timer -= 1
if enemy.vel <= 1:
enemy.bul_cooldown += 0.5//enemy.vel #- 1
if 0.3 <= enemy.vel:
enemy.vel -= 0.03
if self.activation_timer <= 500 and enemy.vel <= 3:
enemy.vel += 0.043
else:
enemy.vel = 3

Loading…
Cancel
Save