-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscoreboard.py
More file actions
33 lines (24 loc) · 769 Bytes
/
scoreboard.py
File metadata and controls
33 lines (24 loc) · 769 Bytes
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
from turtle import Turtle
from playsound import *
ALIGNMENT = "center"
FONT = ("Arial", 18, "normal")
class Scoreboard(Turtle):
def __init__(self):
super().__init__()
self.score = 0
self.color("white")
self.penup()
self.goto(x=0, y=260)
self.write(arg=f"Score = {self.score}", align=ALIGNMENT, font=FONT)
self.hideturtle()
def update_score(self):
self.clear()
self.write(arg=f"Score = {self.score}", align=ALIGNMENT, font=FONT)
def game_over(self):
self.color("red")
self.goto(0, 0)
self.write("GAME OVER", align=ALIGNMENT, font=FONT)
playsound("gameover.wav")
def increment_score(self):
self.score += 1
self.update_score()