Simple plateformer game playing

This commit is contained in:
2026-10-10 13:38:11 +02:00
commit 5cc2f19887
17 changed files with 531 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
from time import sleep
from game.game import Game
from game.handlers.gameHandler import GameHandler
class UserPlayerGameHandler(GameHandler):
KEYBOARD_INPUTS = ["w", "q", "a", "z", "e", "d", "c"]
def __init__(self, game: Game):
super().__init__(game)
def on_position_update(self) -> None:
"""
Refresh the screen
"""
print("\033[2J\033[H" + self.game.to_string())
sleep(0.1)
def on_input_request(self) -> str:
"""
Listen for keyboard input, and map it to a gameState PLAYER_MOVEMENTS
"""
return self.game.gameState.PLAYER_MOVEMENTS[self.KEYBOARD_INPUTS.index(input(f"Enter a movement ({', '.join(self.KEYBOARD_INPUTS)}): "))]