Only refresh entities if the player moved, ignore most events
This commit is contained in:
parent
279d9d9f58
commit
5addd42535
@ -71,7 +71,6 @@ class Game:
|
||||
self.display_refresh()
|
||||
key = screen.getkey()
|
||||
self.handle_key_pressed(self.translate_key(key))
|
||||
self.map.tick()
|
||||
|
||||
def translate_key(self, key: str) -> KeyValues:
|
||||
"""
|
||||
@ -112,13 +111,17 @@ class Game:
|
||||
In play mode, arrows or zqsd should move the main character.
|
||||
"""
|
||||
if key == KeyValues.UP:
|
||||
self.player.move_up()
|
||||
if self.player.move_up():
|
||||
self.map.tick()
|
||||
elif key == KeyValues.DOWN:
|
||||
self.player.move_down()
|
||||
if self.player.move_down():
|
||||
self.map.tick()
|
||||
elif key == KeyValues.LEFT:
|
||||
self.player.move_left()
|
||||
if self.player.move_left():
|
||||
self.map.tick()
|
||||
elif key == KeyValues.RIGHT:
|
||||
self.player.move_right()
|
||||
if self.player.move_right():
|
||||
self.map.tick()
|
||||
elif key == KeyValues.SPACE:
|
||||
self.state = GameMode.MAINMENU
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user