From d0c4bb8b2602c4a28cc15424894eb986483d3b05 Mon Sep 17 00:00:00 2001 From: tsmith37 Date: Sat, 6 Dec 2025 16:20:15 -0500 Subject: [PATCH] The ship can move all diriction and got the asteroid to appear Im thinking i might change the kind of game i want to build to a shooting the aliens and asteroid but i need to figure out how to make the ship shoot and what happens when something hits it. --- .../__pycache__/spaceship.cpython-313.pyc | Bin 1301 -> 1517 bytes .../__pycache__/targets.cpython-313.pyc | Bin 1207 -> 1210 bytes proposal.md/nav_game.py | 6 +++--- proposal.md/spaceship.py | 12 ++++++++++-- proposal.md/targets.py | 6 +++--- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/proposal.md/__pycache__/spaceship.cpython-313.pyc b/proposal.md/__pycache__/spaceship.cpython-313.pyc index 3e4bee6946f247d670d0a7d9aa5f4826f68cf174..1e41537846e510a48f10b0743f76a26023803406 100644 GIT binary patch delta 483 zcmbQr^_H9OGcPX}0}$+(ZIU^gc_ZItM#h%Oj~MM37fn`VGOTwEWej2h$)kc`7OMyb zhC~hqhEV2UW?i6UD2oYG9;?4D4)v^H_3R7`5hg(OKpVlT#c-%*1FL3ZVBi2N2O2*) zmPv{+d~yX-nIpTOCd(}jZ`a6pA6K`KTbv+Pkf*yx$SpPyGc*7q>Ea*mS0n<|TEqe( zL_vfYh!CI5$2_BcBaqp^aD!jCzqYfslcj_42DeDRU8mgzS)a??J~#L!`s+ID7D!#@ z*S?{kxWI8C>w>}=RTFt02ue+tn<%%y`m&%NRtbyCf?yqi3yo(~AkHGl&PXguOfE?+DiQ!0EI&Dr)hB?PRlZ0F#AOB&ewvJ6x=0-)0v6^6 pvTkwM=1$oQQ}m{I-{1CRh~003B2Kve($ diff --git a/proposal.md/__pycache__/targets.cpython-313.pyc b/proposal.md/__pycache__/targets.cpython-313.pyc index 1d4159ed03b8f22fc8636670657e85d6d2897322..190cbfdd6b791c23087e31fe8ae8def84454ab30 100644 GIT binary patch delta 70 zcmdnaxr>wgGcPX}0}$NmH<`#?CCK4eT#{OppPBNK5hTdyKXK}OPC=O9W*f%ejGRJn Ju03-FBLM%=7K;D? delta 67 zcmdnRxt){yGcPX}0}vd(YA}(zN`O5iu_!&Yr1&KxQ0x|?#l&gzIRv0$o9!5XGja&R Jcuvd}i~zsz6?^~y 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