forked from AseanK/python-tools-and-games
-
Notifications
You must be signed in to change notification settings - Fork 0
/
score.py
31 lines (25 loc) · 799 Bytes
/
score.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 score(Turtle):
def __init__(self):
super().__init__()
self.color("white")
self.pu()
self.hideturtle()
self.left_score = 0
self.right_score = 0
self.update()
# Updates scoreboard
def update(self):
self.clear()
self.setpos(-150, 200)
self.write(f"Score: {self.left_score}", align="center", font=('Arial', 18, 'normal'))
self.setpos(150, 200)
self.write(f"Score: {self.right_score}", align="center", font=('Arial', 18, 'normal'))
# Add score to left scoreboard
def left_point(self):
self.left_score += 1
self.update()
# Add score to right scoreboard
def right_point(self):
self.right_score += 1
self.update()