-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscoreboard.py
35 lines (31 loc) · 1.17 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
from turtle import Turtle
class Scoreboard(Turtle):
def __init__(self, position):
super().__init__()
self.hideturtle()
self.penup()
self.goto(position)
self.pendown()
self.pencolor("white")
self.write("0", False, "center", font=('Arial', 20, 'normal'))
def increment_score(self, position, score):
self.hideturtle()
self.clear()
self.penup()
self.goto(position)
self.pendown()
self.pencolor("white")
self.write(f"{score}", False, "center", font=('Arial', 20, 'normal'))
def game_over_winner(self, score1, score2):
if score1 > score2:
self.hideturtle()
self.pencolor("white")
self.write("Player 1 Wins!", False, "center", font=('Arial', 20, 'normal'))
elif score1 < score2:
self.hideturtle()
self.pencolor("white")
self.write("Player 2 Wins!", False, "center", font=('Arial', 20, 'normal'))
else:
self.hideturtle()
self.pencolor("white")
self.write("Tie!", False, "center", font=('Arial', 20, 'normal'))