screenTable.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from turtle import Turtle
  2. from config import SCREEN_HEIGHT
  3. class ScreenTable(Turtle):
  4. def __init__(self):
  5. super().__init__()
  6. self.r_score = 0
  7. self.l_score = 0
  8. self.color('white')
  9. self.penup()
  10. self.hideturtle()
  11. self.goto(0, SCREEN_HEIGHT / 2 - 30)
  12. self.update()
  13. def update(self):
  14. self.clear()
  15. self.goto(0, SCREEN_HEIGHT / 2 - 100)
  16. self.write(f"{self.l_score} : {self.r_score}", True, align="center", font=("Arial", 50, "normal"))
  17. def reset(self):
  18. self.r_score = 0
  19. self.l_score = 0
  20. self.update()
  21. def increase(self, paddle):
  22. if paddle == "r":
  23. self.r_score += 1
  24. elif paddle == "l":
  25. self.l_score += 1
  26. self.update()
  27. def game_over(self):
  28. self.goto(0, 0)
  29. self.write("GAME IS OVER", True, align="center", font=("Arial", 30, "normal"))
  30. def quit(self):
  31. self.goto(0, 0)
  32. self.write("Mouse click to exit", True, align="center", font=("Arial", 30, "normal"))