diff --git a/proposal.md/__pycache__/spaceship.cpython-313.pyc b/proposal.md/__pycache__/spaceship.cpython-313.pyc index 3e4bee6..1e41537 100644 Binary files a/proposal.md/__pycache__/spaceship.cpython-313.pyc and b/proposal.md/__pycache__/spaceship.cpython-313.pyc differ diff --git a/proposal.md/__pycache__/targets.cpython-313.pyc b/proposal.md/__pycache__/targets.cpython-313.pyc index 1d4159e..190cbfd 100644 Binary files a/proposal.md/__pycache__/targets.cpython-313.pyc and b/proposal.md/__pycache__/targets.cpython-313.pyc differ diff --git a/proposal.md/nav_game.py b/proposal.md/nav_game.py index 48adf27..f42aa38 100644 --- a/proposal.md/nav_game.py +++ b/proposal.md/nav_game.py @@ -1,9 +1,9 @@ from retro.game import Game from spaceship import Spaceship -from targets import Targets +from targets import Asteroid board_size = (100, 25) ship = Spaceship(board_size) -targets = Targets((board_size[0] // 2, 0)) -game = Game([ship], {"score": 0}, board_size=board_size, color="white", debug=True) +targets = Asteroid((board_size[0] // 2, 0)) +game = Game([ship, targets], {"score": 0}, board_size=board_size, color="white_on_blue") game.play() \ No newline at end of file diff --git a/proposal.md/spaceship.py b/proposal.md/spaceship.py index cf66e4a..c6149d4 100644 --- a/proposal.md/spaceship.py +++ b/proposal.md/spaceship.py @@ -8,11 +8,19 @@ class Spaceship: def handle_keystroke(self, keystroke, game): x, y = self.position - if keystroke.name in ("KEY_LEFT", "KEY_RIGHT"): + if keystroke.name in ("KEY_LEFT", "KEY_RIGHT", "KEY_UP", "KEY_DOWN"): if keystroke.name == "KEY_LEFT": new_position = (x - 1, y) - else: + + elif keystroke.name == "KEY_RIGHT": new_position = (x + 1, y) + + elif keystroke.name == "KEY_UP": + new_position = (x, y-1) + + elif keystroke.name == "KEY_DOWN": + new_position = (x, y+1) + if game.on_board(new_position): if game.is_empty(new_position): self.position = new_position diff --git a/proposal.md/targets.py b/proposal.md/targets.py index 60fffa0..add21a5 100644 --- a/proposal.md/targets.py +++ b/proposal.md/targets.py @@ -1,5 +1,5 @@ -class Targets: - character = '8' +class Asteroid: + character = 'O' def __init__(self, position): self.position = position @@ -16,4 +16,4 @@ class Targets: if new_position == ship.position: game.end() else: - self.position = new_position + self.position = new_position \ No newline at end of file