-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
37 lines (30 loc) · 791 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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)
player = Player()
car = CarManager()
scoreboard = Scoreboard()
screen.listen()
screen.onkey(player.up, "Up")
game_is_on = True
while game_is_on:
time.sleep(0.1)
screen.update()
car.create_car()
car.move_car()
#Detection collision with cars
for cars in car.allcars:
if cars.distance(player) < 20:
game_is_on = False
scoreboard.game_over()
if player.is_at_finishing_line():
player.go_to_start()
car.level_up()
scoreboard.increase_level()
scoreboard.update_scoreboard()
screen.exitonclick()