Removed timer

This commit is contained in:
Marcin Kostrzewski 2020-05-10 12:53:08 +02:00
parent a76965cd91
commit 01ce5796da

View File

@ -7,22 +7,16 @@ from src.entities.Interactable import Interactable
from src.entities.Pickupable import Pickupable from src.entities.Pickupable import Pickupable
from src.entities.Player import Movement from src.entities.Player import Movement
# Player can move every given milliseconds
TIMEOUT = 100
class EventManager:
keyTimeout = 0
#self.game.map class EventManager:
def __init__(self, gameObject, player): def __init__(self, gameObject, player):
# TODO: Is this really neccessary? # TODO: Is this really necessary?
self.game = gameObject self.game = gameObject
self.player = player self.player = player
self.keyTimer = pygame.time.Clock()
# TODO: Make this not retarded # TODO: Make this not retarded
self.turnOff = False self.turnOff = False
# Player controls
# TODO # TODO
def loadKeyboardSettings(self): def loadKeyboardSettings(self):
@ -39,26 +33,23 @@ class EventManager:
self.game.screen.ui.updateTime() self.game.screen.ui.updateTime()
keys = pygame.key.get_pressed() keys = pygame.key.get_pressed()
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == pygame.QUIT: if event.type == pygame.QUIT:
self.game.running = False self.game.running = False
if event.type == pygame.MOUSEBUTTONUP: if event.type == pygame.MOUSEBUTTONUP:
pos = pygame.mouse.get_pos() pos = pygame.mouse.get_pos()
self.handleClickingOnCollidablesAndTerrains(pos) self.handleClickingOnCollidablesAndTerrains(pos)
# TODO: Move to ui.update() # TODO: Move to ui.update()
self.game.screen.ui.updateBasedOnPygameEvent(event) self.game.screen.ui.updateBasedOnPygameEvent(event)
self.keyTimeout += self.keyTimer.tick()
if self.keyTimeout >= TIMEOUT:
if self.player.alive: if self.player.alive:
# TODO: Add A* here? # TODO: Add A* here?
self.handlePlayerControls(keys) self.handlePlayerControls(keys)
self.keyTimeout = 0
else: else:
self.game.screen.ui.updateOnDeath(self.player) self.game.screen.ui.updateOnDeath(self.player)
self.turnOff = True self.turnOff = True
# TODO: Move to ui.update()
self.game.screen.ui.updateBarsBasedOnPlayerStats(self.player.statistics) self.game.screen.ui.updateBarsBasedOnPlayerStats(self.player.statistics)
def handleClickingOnCollidablesAndTerrains(self, pos): def handleClickingOnCollidablesAndTerrains(self, pos):