Checkpoint 2: Attaching the "asteroid" to the player if the player touches the "asteroid" This part was challenging as there were new commands I learned while trying to incorporate the retro lab componemets. I included the "asteroid sprawner" to get more than on "asteroid" on the screen. The next part is to end the game.

This commit is contained in:
erbrown
2025-12-14 22:07:22 -05:00
parent 0141fafc98
commit 1a02f78bb1
7 changed files with 73 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ class Player:
def __init__(self, board_size):
board_width, board_height = board_size
self.position = (board_width // 2, board_height - 1)
self.attached_apples = []
def handle_keystroke(self, keystroke, game):
x, y = self.position
@@ -22,7 +23,5 @@ class Player:
new_position = (x, y + 1)
if game.on_board(new_position):
if game.is_empty(new_position):
self.position = new_position
else:
game.end()
self.position = new_position
#self.check_self_collision(game)