From 115a96fbf2d77256de46e5a1081c87dceac1f268 Mon Sep 17 00:00:00 2001 From: Unbewohnte Date: Mon, 24 Aug 2020 13:07:01 +0300 Subject: [PATCH] out_of_area`s timer is now in human-readable format ! --- Main.py | 37 +++++++++++++++++++------------------ beings.py | 5 +---- settings.py | 1 + surfaces.py | 5 ++++- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Main.py b/Main.py index bf733ec..64aa0f0 100644 --- a/Main.py +++ b/Main.py @@ -1,7 +1,7 @@ import pygame import pygame_menu import sys -from settings import windowX,windowY, DEBUG, window_caption,logo,gamefont +from settings import windowX,windowY, DEBUG, window_caption,logo,gamefont, FPS from bullets import Bullet from beings import * from surfaces import SlowTimeSurf, BuffRandomSurf @@ -15,7 +15,8 @@ font = pygame.font.Font(gamefont, 46) ################################################################ def play(): - FPS = 70 + if DEBUG == True: + from bullets import player_bullets_on_screen,enemy_bul_on_screen clock = pygame.time.Clock() pygame.mouse.set_visible(False) slowsurf = SlowTimeSurf(384,64) @@ -26,7 +27,9 @@ def play(): enemies_on_screen.append(enemy2) print(enemies_on_screen) player = Player() - death_timer = 70 + + death_timer = 1.5 + death_timer_calculation = (death_timer/70)/death_timer SCORE = 0 ########################## LAYER 0 while True: @@ -43,6 +46,8 @@ def play(): pygame.draw.rect(window,(184, 227, 179, 1),(row,0,2,windowY)) for column in range(0,windowY,64): pygame.draw.rect(window,(184, 227, 179),(0,column,windowX,2)) + #print('power_of_random: ',player.power_of_random) + print('bullets_on_screen: ', str(len(player_bullets_on_screen + enemy_bul_on_screen))) ########################## LAYER 0 END @@ -51,7 +56,7 @@ def play(): if slowsurf.switch == True: slowsurf.place(window) if slowsurf.collide(player.player_rect): - print("Colliding !") + print("") slowsurf.switch = False else: #for enemy in enemies_on_screen: #Doesn`t work and I don`t know why @@ -61,7 +66,7 @@ def play(): if randsurf.switch == True: randsurf.place(window) if randsurf.collide(player.player_rect): - print('Random !!!') + print('') randsurf.switch = False else: randsurf.activate(player) @@ -75,15 +80,19 @@ def play(): player.collision(window) if player.out_of_area(): - death_timer -= 1 - timertext_color = (255-death_timer-60,3.6*death_timer,10) - text = font.render(str(death_timer), True, timertext_color) + death_timer -= death_timer_calculation + timertext_color = (255-death_timer*150,170*death_timer,10) + text = font.render(str(round(death_timer,2)), True, timertext_color) window.blit(text,(windowX//2,windowY//2 - 100)) - if death_timer <= 1: + if death_timer < 0.1: print('DED') + if DEBUG == True: + print('TOTAL {}'.format(time.time()-start)) break else: - death_timer = 70 + if DEBUG == True: + start = time.time() + death_timer = 1.5 ########################## LAYER 1 END @@ -115,14 +124,6 @@ def play(): print('Win-win') 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 3 diff --git a/beings.py b/beings.py index be2984e..ad215d9 100644 --- a/beings.py +++ b/beings.py @@ -35,9 +35,7 @@ class Player: self.y += self.vel def draw(self,window): - #(self.x,self.y,self.width,self.height) self.player_rect = pygame.Rect(self.x, self.y, self.width, self.height) - #pygame.draw.rect(window,(0,0,0),(self.player_rect[0],self.player_rect[1],self.player_rect[2],self.player_rect[3])) window.blit(player_image,(self.player_rect[0], self.player_rect[1])) @@ -62,7 +60,7 @@ class Player: self.vel = 10 if self.tp_cooldown >= 1: self.tp_cooldown -= 2 - print('teleportation cooldown : '+ str(self.tp_cooldown)) + #print('teleportation cooldown : '+ str(self.tp_cooldown)) keys = pygame.key.get_pressed() if keys[pygame.K_d] and keys[pygame.K_UP] and self.tp_cooldown == 0: #forward-dash @@ -140,7 +138,6 @@ class Enemy: if bullet.bullet_rect[1] >= windowY +20: enemy_bul_on_screen.remove(bullet) - #print('Bullets (Enemy,Player): ' + str(len(bullets_on_screen + enemy_bul_on_screen))) def out_of_area(self): if self.enemy_x > windowX+1 or self.enemy_x < -1 or self.enemy_y > windowY+1 or self.enemy_y < -1: diff --git a/settings.py b/settings.py index f375b43..526a786 100644 --- a/settings.py +++ b/settings.py @@ -13,5 +13,6 @@ gamefont = 'freesansbold.ttf' ############ windowX = 832 windowY = 832 +FPS = 70 ############ DEBUG = False diff --git a/surfaces.py b/surfaces.py index 55c6536..73521fe 100644 --- a/surfaces.py +++ b/surfaces.py @@ -1,5 +1,8 @@ import pygame -from settings import timesurf_image, randsurf_image +from settings import timesurf_image, randsurf_image, gamefont + +pygame.font.init() +surf_font = pygame.font.Font(gamefont, 46) class BuffRandomSurf: def __init__(self,surf_x,surf_y):