Browse Source

out_of_area`s timer is now in human-readable format !

master
Unbewohnte 4 years ago
parent
commit
115a96fbf2
  1. 37
      Main.py
  2. 5
      beings.py
  3. 1
      settings.py
  4. 5
      surfaces.py

37
Main.py

@ -1,7 +1,7 @@
import pygame import pygame
import pygame_menu import pygame_menu
import sys 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 bullets import Bullet
from beings import * from beings import *
from surfaces import SlowTimeSurf, BuffRandomSurf from surfaces import SlowTimeSurf, BuffRandomSurf
@ -15,7 +15,8 @@ font = pygame.font.Font(gamefont, 46)
################################################################ ################################################################
def play(): def play():
FPS = 70 if DEBUG == True:
from bullets import player_bullets_on_screen,enemy_bul_on_screen
clock = pygame.time.Clock() clock = pygame.time.Clock()
pygame.mouse.set_visible(False) pygame.mouse.set_visible(False)
slowsurf = SlowTimeSurf(384,64) slowsurf = SlowTimeSurf(384,64)
@ -26,7 +27,9 @@ def play():
enemies_on_screen.append(enemy2) enemies_on_screen.append(enemy2)
print(enemies_on_screen) print(enemies_on_screen)
player = Player() player = Player()
death_timer = 70
death_timer = 1.5
death_timer_calculation = (death_timer/70)/death_timer
SCORE = 0 SCORE = 0
########################## LAYER 0 ########################## LAYER 0
while True: while True:
@ -43,6 +46,8 @@ def play():
pygame.draw.rect(window,(184, 227, 179, 1),(row,0,2,windowY)) pygame.draw.rect(window,(184, 227, 179, 1),(row,0,2,windowY))
for column in range(0,windowY,64): for column in range(0,windowY,64):
pygame.draw.rect(window,(184, 227, 179),(0,column,windowX,2)) 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 ########################## LAYER 0 END
@ -51,7 +56,7 @@ def play():
if slowsurf.switch == True: if slowsurf.switch == True:
slowsurf.place(window) slowsurf.place(window)
if slowsurf.collide(player.player_rect): if slowsurf.collide(player.player_rect):
print("Colliding !") print("<Sakuya slows the flow of time !>")
slowsurf.switch = False slowsurf.switch = False
else: else:
#for enemy in enemies_on_screen: #Doesn`t work and I don`t know why #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: if randsurf.switch == True:
randsurf.place(window) randsurf.place(window)
if randsurf.collide(player.player_rect): if randsurf.collide(player.player_rect):
print('Random !!!') print('<Randoumu no pawa~ !>')
randsurf.switch = False randsurf.switch = False
else: else:
randsurf.activate(player) randsurf.activate(player)
@ -75,15 +80,19 @@ def play():
player.collision(window) player.collision(window)
if player.out_of_area(): if player.out_of_area():
death_timer -= 1 death_timer -= death_timer_calculation
timertext_color = (255-death_timer-60,3.6*death_timer,10) timertext_color = (255-death_timer*150,170*death_timer,10)
text = font.render(str(death_timer), True, timertext_color) text = font.render(str(round(death_timer,2)), True, timertext_color)
window.blit(text,(windowX//2,windowY//2 - 100)) window.blit(text,(windowX//2,windowY//2 - 100))
if death_timer <= 1: if death_timer < 0.1:
print('DED') print('DED')
if DEBUG == True:
print('TOTAL {}'.format(time.time()-start))
break break
else: else:
death_timer = 70 if DEBUG == True:
start = time.time()
death_timer = 1.5
########################## LAYER 1 END ########################## LAYER 1 END
@ -115,14 +124,6 @@ def play():
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

@ -35,9 +35,7 @@ class Player:
self.y += self.vel self.y += self.vel
def draw(self,window): 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) 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])) window.blit(player_image,(self.player_rect[0], self.player_rect[1]))
@ -62,7 +60,7 @@ class Player:
self.vel = 10 self.vel = 10
if self.tp_cooldown >= 1: if self.tp_cooldown >= 1:
self.tp_cooldown -= 2 self.tp_cooldown -= 2
print('teleportation cooldown : '+ str(self.tp_cooldown)) #print('teleportation cooldown : '+ str(self.tp_cooldown))
keys = pygame.key.get_pressed() keys = pygame.key.get_pressed()
if keys[pygame.K_d] and keys[pygame.K_UP] and self.tp_cooldown == 0: #forward-dash 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: if bullet.bullet_rect[1] >= windowY +20:
enemy_bul_on_screen.remove(bullet) enemy_bul_on_screen.remove(bullet)
#print('Bullets (Enemy,Player): ' + str(len(bullets_on_screen + enemy_bul_on_screen)))
def out_of_area(self): 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: if self.enemy_x > windowX+1 or self.enemy_x < -1 or self.enemy_y > windowY+1 or self.enemy_y < -1:

1
settings.py

@ -13,5 +13,6 @@ gamefont = 'freesansbold.ttf'
############ ############
windowX = 832 windowX = 832
windowY = 832 windowY = 832
FPS = 70
############ ############
DEBUG = False DEBUG = False

5
surfaces.py

@ -1,5 +1,8 @@
import pygame 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: class BuffRandomSurf:
def __init__(self,surf_x,surf_y): def __init__(self,surf_x,surf_y):

Loading…
Cancel
Save