Files
project_game/player.py
juddin2 8769519960 I made sure my circles are falling continously and as the player doges the score increases.
I'm proud of making the circles fall from the top one at a time.
I was stuck on making the circle fall.
2025-12-04 21:14:43 -05:00

26 lines
847 B
Python

class Player:
name = "player"
character = '^'
def __init__(self, board_size):
board_width, board_height = board_size
self.position = (board_width // 2, board_height - 1)
def handle_keystroke(self, keystroke, game):
x, y = self.position
if keystroke.name == "KEY_LEFT":
new_position = (x - 1, y)
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)
else:
return
if game.on_board(new_position):
if game.is_empty(new_position):
self.position = new_position
else:
game.end()