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()
|
self.display_refresh()
|
||||||
key = screen.getkey()
|
key = screen.getkey()
|
||||||
self.handle_key_pressed(self.translate_key(key))
|
self.handle_key_pressed(self.translate_key(key))
|
||||||
self.map.tick()
|
|
||||||
|
|
||||||
def translate_key(self, key: str) -> KeyValues:
|
def translate_key(self, key: str) -> KeyValues:
|
||||||
"""
|
"""
|
||||||
|
@ -112,13 +111,17 @@ class Game:
|
||||||
In play mode, arrows or zqsd should move the main character.
|
In play mode, arrows or zqsd should move the main character.
|
||||||
"""
|
"""
|
||||||
if key == KeyValues.UP:
|
if key == KeyValues.UP:
|
||||||
self.player.move_up()
|
if self.player.move_up():
|
||||||
|
self.map.tick()
|
||||||
elif key == KeyValues.DOWN:
|
elif key == KeyValues.DOWN:
|
||||||
self.player.move_down()
|
if self.player.move_down():
|
||||||
|
self.map.tick()
|
||||||
elif key == KeyValues.LEFT:
|
elif key == KeyValues.LEFT:
|
||||||
self.player.move_left()
|
if self.player.move_left():
|
||||||
|
self.map.tick()
|
||||||
elif key == KeyValues.RIGHT:
|
elif key == KeyValues.RIGHT:
|
||||||
self.player.move_right()
|
if self.player.move_right():
|
||||||
|
self.map.tick()
|
||||||
elif key == KeyValues.SPACE:
|
elif key == KeyValues.SPACE:
|
||||||
self.state = GameMode.MAINMENU
|
self.state = GameMode.MAINMENU
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue