-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscore_board.py
36 lines (29 loc) · 869 Bytes
/
score_board.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
from turtle import Turtle
# declare constant variable
ALIGNMENT = 'center'
FONT = ("Arial", 15, "normal")
class ScoreBoard(Turtle):
"""
This class is to create keep to tack of score of the game"""
def __init__(self):
super().__init__()
self.score = 0
self.pencolor("white")
self.penup()
self.goto(0, 270)
self.hideturtle()
self.update_score()
def increase_score(self):
self.score += 1
self.clear()
self.update_score()
def update_score(self):
"""
This mathod is to update score"""
self.write(f"Score: {self.score}", align=ALIGNMENT,
font=FONT)
def game_over(self):
"""
This method is display game over message"""
self.goto(0, 0)
self.write("GAME OVER!!!", align=ALIGNMENT, font=FONT)