diff --git a/Main.py b/Main.py index 8f36c8c..3677e05 100644 --- a/Main.py +++ b/Main.py @@ -6,7 +6,6 @@ import time from bullets import Bullet from beings import * from surfaces import Surface - ######## Set up things that will not change pygame.init() pygame.display.set_caption('Healthless') @@ -16,6 +15,8 @@ window = pygame.display.set_mode((windowX,windowY)) icon = pygame.image.load('pics/logo.png') pygame.display.set_icon(icon) +# font = pygame.font.Font('freesansbold.ttf', 32) +# text = font.render('5', True,(100,100,100)) bullet_image = pygame.image.load('pics/second_bullet.png') enemy_bul_img = pygame.image.load('pics/bullet.png') @@ -31,7 +32,9 @@ def play(): pygame.mouse.set_visible(False) enemy = Enemy() player = Player() - test_surface = Surface() + death_timer = 70 + # lower_surface = Surface('killsurf') + # main_surface = Surface('default') while True: for event in pygame.event.get(): @@ -42,29 +45,37 @@ def play(): window.fill((41, 64, 59)) # (41,64,59) - test_surface.place(window,100,100) + # lower_surface.place(window,0,0) + # main_surface.place(window,145,145) player.teleportation() player.shoot(window,start_color,bullet_image) player.draw(window,start_color,player_image) player.update(window,start_color,bullet_image) player.collision() + if player.out_of_area(): + death_timer -= 1 + print('death_timer',death_timer) + if death_timer <= 0: + print('DED') + break + else: + death_timer = 70 + enemy.enemy_shoot(window,start_color,enemy_bul_img) enemy.draw(window,start_color,enemy_image) enemy.move('right') + if enemy.enemy_x == windowX: enemy.enemy_x = 1 enemy.collision() - if player.out_of_area(): - print(player.x, player.y) - break - if enemy.out_of_area(): print('Random is on our side') break + clock.tick(FPS) pygame.display.update() pass diff --git a/beings.py b/beings.py index bccdeb8..9c15585 100644 --- a/beings.py +++ b/beings.py @@ -25,16 +25,16 @@ class Player: def update(self,window,start_color,bul_image): keys = pygame.key.get_pressed() - if keys[pygame.K_LEFT] and self.x > 5 : + if keys[pygame.K_LEFT] and self.x - self.vel > 5 : self.x -= self.vel if keys[pygame.K_RIGHT] and self.x < windowX- self.width - 5 : self.x += self.vel - if keys[pygame.K_UP] and self.y + self.height > self.height + 5 : + if keys[pygame.K_UP] and self.y + self.height - self.vel > self.height + 5 : self.y -= self.vel - if keys[pygame.K_DOWN] and self.y + self.height < windowY-15 : + if keys[pygame.K_DOWN] and self.y + self.height + self.vel < windowY-15 : self.y += self.vel def draw(self,window,color,player_image): @@ -89,15 +89,15 @@ class Player: # self.tp_cooldown = 100 def out_of_area(self): - if self.x > windowX or self.x < 0 or self.y > windowY or self.y < 0: + if self.x + self.width > windowX or self.x < 0 or self.y+self.height > windowY or self.y < 0: return True else: return False def collision(self): for bullet in enemy_bul_on_screen: if bullet.bullet_x + bullet.bullet_width/2 >= self.x and bullet.bullet_x + bullet.bullet_width/2 <= self.x + self.width and bullet.bullet_y <= self.y: - self.x += randint(-50,50) - self.y += randint(-50,50) + self.x += randint(-100,100) + self.y += randint(-100,100) @@ -140,5 +140,5 @@ class Enemy: for bullet in bullets_on_screen: # if bullet.bullet_x + bullet.bullet_width/2 >= enemy.enemy_x and bullet.bullet_x + bullet.bullet_width/2 <= enemy.enemy_x + enemy.en_width and bullet.bullet_y <= enemy.enemy_y: if bullet.bullet_x + bullet.bullet_width/2 >= self.enemy_x and bullet.bullet_x + bullet.bullet_width/2 <= self.enemy_x + self.en_width and bullet.bullet_y <= self.enemy_y: - self.enemy_x += randint(-50,50) - self.enemy_y += randint(-50,50) + self.enemy_x += randint(-60,60) + self.enemy_y += randint(-60,60) diff --git a/surfaces.py b/surfaces.py index 684c2eb..6835556 100644 --- a/surfaces.py +++ b/surfaces.py @@ -1,12 +1,16 @@ import pygame +from beings import * class Surface: - def __init__(self): - self.width = 64 - self.height = 64 - - def killsurf(self): #Don`t quite understand what I`ll do with these - pass + def __init__(self,name): + if str(name) == 'killsurf': + self.width = windowX + self.height = windowY + self.color = (30,70,40) + if str(name) == 'default': + self.width = windowX/1.5 + self.height = windowY/1.5 + self.color = (50,20,60) def place(self,window,surf_x,surf_y): - pygame.draw.rect(window,(100,200,240),(surf_x,surf_y,self.width,self.height)) + pygame.draw.rect(window,self.color,(surf_x,surf_y,self.width,self.height))