The Turtle Crossing Capstione

2022-05-02.png

FireShot Capture 042 - 100 Days of Code_ The Complete Python Pro Bootcamp for 2022 - Udemy_ - www.udemy.com.png

2022-05-02 (1).png

main.py

import time
from turtle import Screen
from player import Player
from car_manager import CarManager
from scoreboard import Scoreboard

screen = Screen()
screen.setup(width=600, height=600)
screen.tracer(0)

game_is_on = True
while game_is_on:
    time.sleep(0.1)
    screen.update()
car_manager.py

COLORS = ["red", "orange", "yellow", "green", "blue", "purple"]
STARTING_MOVE_DISTANCE = 5
MOVE_INCREMENT = 10

class CarManager:
    pass
player.py

STARTING_POSITION = (0, -280)
MOVE_DISTANCE = 10
FINISH_LINE_Y = 280

class Player:
    pass
scoreborad.py

FONT = ("Courier", 24, "normal")

class Scoreboard:
    pass

Create the Player Behaviour

FireShot Capture 043 - 100 Days of Code_ The Complete Python Pro Bootcamp for 2022 - Udemy_ - www.udemy.com.png

player.py

from turtle import Turtle

STARTING_POSITION = (0, -280)
MOVE_DISTANCE = 10
FINISH_LINE_Y = 280

class Player(Turtle):

    def __init__(self):
        super().__init__()
        self.shape('turtle')
        self.penup()
        self.color('black')
        self.setheading(90)
        self.go_start()

    def go_up(self):
        self.forward(MOVE_DISTANCE)

    def go_start(self):
        self.goto(STARTING_POSITION)

    def is_go_to_end_line(self):
        if self.ycor() > FINISH_LINE_Y:
            return True