Files
project_game/frog.py
mollychi 621a680676 I was able to solve all my bugs to get my code to look EXACTLY how i wanted to.
I used AI to help me through some issues, but all the coding I understood and worked through and typed on my own
I learned a lot about the structure and when AI would suggest something I could be like thats now going to solve my issue I need to do this which felt very motivating
2025-12-14 12:47:15 -05:00

25 lines
765 B
Python

class Frog:
name = "froggy"
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 in ("KEY_LEFT", "KEY_RIGHT"):
if keystroke.name == "KEY_LEFT":
new_position = (x - 1, y)
elif keystroke.name == "KEY_RIGHT":
new_position = (x + 1, y)
else:
return
if not game.on_board(new_position):
return
if not game.is_empty(new_position):
game.end()
self.position = new_position