Advertisement
JkSoftware

scoreboard.py

Dec 5th, 2021
613
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. from turtle import Turtle
  2.  
  3.  
  4. class Scoreboard(Turtle):
  5.  
  6.     def __init__(self):
  7.         super().__init__()
  8.         self.score = 0
  9.         self.color("white")
  10.         self.hideturtle()
  11.         self.penup()
  12.         self.goto(0, 265)
  13.         self.update_scoreboard()
  14.  
  15.     def update_scoreboard(self):
  16.         self.write(f"Score = {self.score}", align="center", font=("Courier", 24, "normal"))
  17.  
  18.     def increase_score(self):
  19.         self.score += 1
  20.         self.clear()
  21.         self.update_scoreboard()
  22.  
  23.     def game_over(self):
  24.         self.goto(0, 0)
  25.         self.write("GAME OVER", align="center", font=("Courier", 24, "normal"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement