-
Notifications
You must be signed in to change notification settings - Fork 0
/
scoreboard.py
70 lines (52 loc) · 1.71 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from turtle import Turtle
ALIGN = "center"
FONT = ("Courier", 15, "bold")
# This will do our task of writing
class Scoreboard(Turtle):
def __init__(self, player, escore, hscore):
super().__init__()
self.name_of_player = player
self.hideturtle()
self.color("white")
self.score = escore
self.hscore = hscore
self.write_score()
def get_score(self):
s = self.score
return s
def write_score(self):
self.penup()
self.goto(0, 270)
self.write(f"Score: {self.score}", align=ALIGN, font=FONT)
def update_score(self):
self.score += 1
self.clear()
self.write_score()
def game_over(self):
self.penup()
self.goto(0, 0)
self.write(f"GAME OVER", align=ALIGN, font=FONT)
def write_player_name(self):
n = self.name_of_player
new_turt = Turtle()
new_turt.hideturtle()
new_turt.color("white")
new_turt.penup()
new_turt.goto(-280, 270)
new_turt.write(f"Hi {n}!", align="left", font=FONT)
def write_init_hscore(self):
n = self.name_of_player
new_turt = Turtle()
new_turt.hideturtle()
new_turt.color("white")
new_turt.penup()
new_turt.goto(200, 270)
new_turt.write(f"High score: {self.hscore}", align=ALIGN, font=FONT)
def write_highscore(self, hscore):
n = self.name_of_player
n_turt = Turtle()
n_turt.hideturtle()
n_turt.color("white")
n_turt.penup()
n_turt.goto(0, 240)
n_turt.write(f"Yor High score {hscore}", align=ALIGN, font=FONT)