-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscoreboard.py
32 lines (25 loc) · 865 Bytes
/
scoreboard.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
from turtle import Turtle
class Scoreboard(Turtle):
def __init__(self):
super(Scoreboard, self).__init__()
self.color("white")
self.penup()
self.hideturtle()
self.l_score = 0
self.r_score = 0
self.update_scoreboard()
def update_scoreboard(self):
self.clear()
self.goto(-100, 200)
self.write(self.l_score, align="center", font=("Courier", 80, "normal"))
self.goto(100, 200)
self.write(self.r_score, align="center", font=("Courier", 80, "normal"))
def increase_lscore(self):
self.l_score += 1
self.update_scoreboard()
def increase_rscore(self):
self.r_score += 1
self.update_scoreboard()
def game_over(self):
self.goto(0, 0)
self.write("Game Over", align="center", font=("Courier", 100, "bold"))