improved performance
This commit is contained in:
parent
29f5d4f645
commit
5adde7b48d
16
game.py
16
game.py
|
@ -23,10 +23,11 @@ class Game:
|
||||||
Runs the game
|
Runs the game
|
||||||
"""
|
"""
|
||||||
self.instance_character(3, 3, self.player)
|
self.instance_character(3, 3, self.player)
|
||||||
while not self.should_exit:
|
|
||||||
self.render()
|
self.render()
|
||||||
self.step()
|
while not self.should_exit:
|
||||||
self.ticks += 1
|
action_was_performed = self.step()
|
||||||
|
if action_was_performed:
|
||||||
|
self.render()
|
||||||
|
|
||||||
def instance_character(self, x, y, character: Character):
|
def instance_character(self, x, y, character: Character):
|
||||||
"""
|
"""
|
||||||
|
@ -59,6 +60,9 @@ class Game:
|
||||||
self.term.put_char(x, y, TEXTURES[self.floor.get_tile(x, y)])
|
self.term.put_char(x, y, TEXTURES[self.floor.get_tile(x, y)])
|
||||||
|
|
||||||
def step(self):
|
def step(self):
|
||||||
|
"""
|
||||||
|
Perfoms a step in the game. Returns True if any creature did an action, and False otherwise
|
||||||
|
"""
|
||||||
creaturas = self.schedule.get(self.ticks)
|
creaturas = self.schedule.get(self.ticks)
|
||||||
if creaturas:
|
if creaturas:
|
||||||
for creatura in creaturas:
|
for creatura in creaturas:
|
||||||
|
@ -69,6 +73,12 @@ class Game:
|
||||||
self.reschedule(creatura)
|
self.reschedule(creatura)
|
||||||
self.perform(creatura)
|
self.perform(creatura)
|
||||||
self.schedule.pop(self.ticks)
|
self.schedule.pop(self.ticks)
|
||||||
|
self.ticks += 1
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
self.ticks += 1
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def perform(self, character: Character):
|
def perform(self, character: Character):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue