-
Notifications
You must be signed in to change notification settings - Fork 0
/
scoreboard.py
40 lines (31 loc) · 974 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
32
33
34
35
36
37
38
39
40
from turtle import Turtle
ALIGNMENT = "center"
FONT = ("Arial Black", 30, 'normal')
class ScoreBoard(Turtle):
def __init__(self):
super().__init__()
self.penup()
self.hideturtle()
self.color("white")
self.l_score = 0
self.r_score = 0
self.update_score()
def update_score(self):
self.clear()
self.goto(-100, 200)
self.write(self.l_score, align=ALIGNMENT, font=FONT)
self.goto(100, 200)
self.write(self.r_score, align=ALIGNMENT, font=FONT)
def l_point(self):
self.l_score += 1
self.update_score()
def r_point(self):
self.r_score += 1
self.update_score()
def increase_score(self, score):
self.score += 1
self.undo()
self.update_score(self.score)
def game_over(self):
self.goto(0, 0)
self.write("GAME OVER!", align=ALIGNMENT, font=FONT)