diff --git a/Main.py b/Main.py index a74a139..201cdce 100644 --- a/Main.py +++ b/Main.py @@ -3,7 +3,7 @@ import pygame_menu import sys from bullets import Bullet from beings import * -from surfaces import Surface +from surfaces import SlowTimeSurf from particles import * ######## Set up things that will not change pygame.init() @@ -21,6 +21,7 @@ def play(): FPS = 70 clock = pygame.time.Clock() pygame.mouse.set_visible(False) + slowsurf = SlowTimeSurf(400,20) enemy = Enemy(100,100) enemy2 = Enemy(windowX,200) player = Player() @@ -47,11 +48,21 @@ def play(): ########################## #PPPPPPPPPPPPPPPPPPPPPPPPP + slowsurf.place(window) + if slowsurf.collide(player.player_rect): + enemy.vel -= 0.1 + enemy2.vel -= 0.1 + print("Colliding !") + else: + enemy.vel = 3 + enemy2.vel = 3 + player.teleportation() player.shoot(window) player.draw(window) player.update() player.collision(window) + if player.out_of_area(): death_timer -= 1 timertext_color = (255-death_timer-60,3.6*death_timer,10) @@ -62,6 +73,7 @@ def play(): break else: death_timer = 70 + #PPPPPPPPPPPPPPPPPPPPPPPPP #EEEEEEEEEEEEEEEEEEEEEEEEE diff --git a/beings.py b/beings.py index 8b8a386..120a681 100644 --- a/beings.py +++ b/beings.py @@ -3,18 +3,20 @@ from random import randint from time import time from bullets import * from particles import * +from images import * import time import sys ############ windowX = 832 windowY = 832 -############ imgs for player-enemy(self,bullet) -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') -############ +# ############ imgs for player-enemy(self,bullet), surfaces +# 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') +# timesurf_image = pygame.image.load('pics/timesurf.png') +# ############ class Player: def __init__(self): @@ -28,16 +30,16 @@ class Player: self.player_rect = pygame.Rect(self.x, self.y, self.width, self.height) def update(self): keys = pygame.key.get_pressed() - if keys[pygame.K_LEFT] and self.x - self.vel > 5 : + if keys[pygame.K_LEFT] and self.x - self.vel > 0 : self.x -= self.vel - if keys[pygame.K_RIGHT] and self.x + self.vel < windowX- self.width - 5 : + if keys[pygame.K_RIGHT] and self.x + self.width + self.vel < windowX: self.x += self.vel - if keys[pygame.K_UP] and self.y + self.height - self.vel > self.height + 5 : + if keys[pygame.K_UP] and self.y - self.vel > 0: self.y -= self.vel - if keys[pygame.K_DOWN] and self.y + self.height + self.vel < windowY-15 : + if keys[pygame.K_DOWN] and self.y + self.height + self.vel < windowY : self.y += self.vel def draw(self,window): @@ -87,7 +89,7 @@ class Player: self.tp_cooldown = 100 def out_of_area(self): - if self.x + self.width > windowX or self.x < 0 or self.y+self.height > windowY or self.y < 0: + if self.x + self.width > windowX+3 or self.x < 0 - 3 or self.y+self.height > windowY+3 or self.y < 0 -3: return True else: return False diff --git a/images.py b/images.py new file mode 100644 index 0000000..9b146cb --- /dev/null +++ b/images.py @@ -0,0 +1,9 @@ +import pygame + +############ imgs for player-enemy(self,bullet), surfaces +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') +timesurf_image = pygame.image.load('pics/timesurf.png') +############ diff --git a/pics/timesurf.png b/pics/timesurf.png new file mode 100644 index 0000000..43b8d60 Binary files /dev/null and b/pics/timesurf.png differ diff --git a/surfaces.py b/surfaces.py index ec1a859..3ff9735 100644 --- a/surfaces.py +++ b/surfaces.py @@ -1,12 +1,30 @@ import pygame from beings import * - +from images import timesurf_image class Surface: - def __init__(self,name): - if str(name) == 'killsurf': - self.width = windowX - self.height = windowY + def __init__(self,surf_x,surf_y): + self.x = surf_x + self.y = surf_y + self.width = 32 + self.height = 64 self.color = (30,70,40) - + 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,(surf_x,surf_y,self.width,self.height)) + pygame.draw.rect(window,self.color,self.rect) + +class SlowTimeSurf: + def __init__(self,surf_x,surf_y): + self.x = surf_x + self.y = surf_y + self.width = 32 + self.height = 64 + self.color = (0,0,0) + self.rect = pygame.Rect(self.x, self.y, self.width, self.height) + def place(self,window): + pygame.draw.rect(window,self.color,self.rect) + window.blit(timesurf_image,(self.rect[0], self.rect[1])) + def collide(self,object): + if self.rect.colliderect(object): + return True + else: + return False