-
Notifications
You must be signed in to change notification settings - Fork 0
/
scoreboard.py
48 lines (40 loc) · 1.36 KB
/
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
41
42
43
44
45
46
47
48
# Imports
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.update_score()
def update_score(self):
self.color('red')
self.goto(-100, 270)
self.write("Player 1", align='center', font=('Courier', 12, 'normal'))
self.color('white')
self.goto(-100, 200)
self.write(self.l_score, align='center', font=('Courier', 50, 'normal'))
self.color('cyan')
self.goto(100, 270)
self.write("Player 2", align='center', font=('Courier', 12, 'normal'))
self.color('white')
self.goto(100, 200)
self.write(self.r_score, align='center', font=('Courier', 50, 'normal'))
def l_point(self):
self.l_score += 1
self.clear()
self.update_score()
def r_point(self):
self.r_score += 1
self.clear()
self.update_score()
def p1_wins(self):
self.goto(0, 50)
text = "Player 1 wins!"
self.write(text, align='center', font=('Courier', 50, 'normal'))
def p2_wins(self):
self.goto(0, 50)
text = "Player 2 wins!"
self.write(text, align='center', font=('Courier', 50, 'normal'))