Scaffold the project: pyproject, gitignore, constants, Doxyfile, README, CI
Task: MIL-002#1 Task: MIL-002#2 Task: MIL-002#3 Task: MIL-002#4 Task: MIL-002#5
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
"""@file car_manager.py
|
||||
@brief Creates and moves the cars.
|
||||
"""
|
||||
|
||||
|
||||
class CarManager:
|
||||
"""@brief Placeholder, implemented in milestone MIL-004."""
|
||||
@@ -0,0 +1,35 @@
|
||||
"""@file constants.py
|
||||
@brief Every constant of the Turtle Crossing game, defined once.
|
||||
"""
|
||||
|
||||
## Screen size in pixels.
|
||||
SCREEN_WIDTH = 600
|
||||
SCREEN_HEIGHT = 600
|
||||
## Seconds to sleep between two frames of the game loop.
|
||||
LOOP_DELAY = 0.1
|
||||
|
||||
## Where the player starts, and how far one key press moves it.
|
||||
STARTING_POSITION = (0, -280)
|
||||
MOVE_DISTANCE = 10
|
||||
## The player has crossed when its y coordinate is above this value.
|
||||
FINISH_LINE_Y = 280
|
||||
## Half the width and height of the player used for collision tests.
|
||||
PLAYER_HALF_SIZE = 8
|
||||
|
||||
## Car colours, one registered shape per colour.
|
||||
COLORS = ["red", "orange", "yellow", "green", "blue", "purple"]
|
||||
## Distance a car moves per frame on level 1, and the speed-up per level.
|
||||
STARTING_MOVE_DISTANCE = 5
|
||||
MOVE_INCREMENT = 10
|
||||
## Car footprint in pixels; the drawn shape fits inside it.
|
||||
CAR_LENGTH = 40
|
||||
CAR_HEIGHT = 20
|
||||
## A new car is created when a die with this many sides shows 1.
|
||||
SPAWN_ODDS = 6
|
||||
## No cars in the top and bottom strip of this height.
|
||||
SAFE_ZONE = 50
|
||||
|
||||
## Scoreboard text.
|
||||
FONT = ("Courier", 24, "normal")
|
||||
SCOREBOARD_POSITION = (-280, 250)
|
||||
GAME_OVER_TEXT = "GAME OVER"
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
"""@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()
|
||||
@@ -0,0 +1,7 @@
|
||||
"""@file player.py
|
||||
@brief The turtle the user controls.
|
||||
"""
|
||||
|
||||
|
||||
class Player:
|
||||
"""@brief Placeholder, implemented in milestone MIL-003."""
|
||||
@@ -0,0 +1,7 @@
|
||||
"""@file scoreboard.py
|
||||
@brief Shows the level and the game over message.
|
||||
"""
|
||||
|
||||
|
||||
class Scoreboard:
|
||||
"""@brief Placeholder, implemented in milestone MIL-006."""
|
||||
Reference in New Issue
Block a user