-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScoreboard
35 lines (27 loc) · 978 Bytes
/
Scoreboard
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
from turtle import Turtle
class Scoreboard(Turtle):
def __init__(self):
super().__init__()
self.color("white")
self.penup()
self.hideturtle()
self.l_score = 0
self.r_score = 0
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 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 l_point(self):
self.l_score += 1
self.update_scoreboard()
print(f"r_score = {self.r_score}")
def r_point(self):
self.r_score += 1
self.update_scoreboard()
print(f"l_score = {self.l_score}")