Add the Player class and the Up key binding

Task: MIL-003#1
Task: MIL-003#2
Task: MIL-003#3
This commit is contained in:
2026-10-13 13:56:40 +08:00
parent 8632d60518
commit 71498a9f67
6 changed files with 159 additions and 30 deletions
+31 -27
View File
@@ -1,27 +1,31 @@
"""@file main.py
@brief Entry point: sets up the screen and runs the game loop.
"""
import time
from turtle import Screen
from car_manager import CarManager
from constants import LOOP_DELAY, SCREEN_HEIGHT, SCREEN_WIDTH
from player import Player
from scoreboard import Scoreboard
def main() -> None:
"""@brief Run the game until the player is hit by a car."""
screen = Screen()
screen.setup(width=SCREEN_WIDTH, height=SCREEN_HEIGHT)
screen.tracer(0)
game_is_on = True
while game_is_on:
time.sleep(LOOP_DELAY)
screen.update()
if __name__ == "__main__":
main()
"""@file main.py
@brief Entry point: sets up the screen and runs the game loop.
"""
import time
from turtle import Screen
from car_manager import CarManager
from constants import LOOP_DELAY, SCREEN_HEIGHT, SCREEN_WIDTH
from player import Player
from scoreboard import Scoreboard
def main() -> None:
"""@brief Run the game until the player is hit by a car."""
screen = Screen()
screen.setup(width=SCREEN_WIDTH, height=SCREEN_HEIGHT)
screen.tracer(0)
player = Player()
screen.listen()
screen.onkey(player.go_up, "Up")
game_is_on = True
while game_is_on:
time.sleep(LOOP_DELAY)
screen.update()
if __name__ == "__main__":
main()