from turtle import Turtle
class ScoreBoard(Turtle):
    def __init__(self):
        super().__init__()
        self.score= 0
        with open("data.txt") as data:
          self.high_score= int(data.read())
        self.color("white")
        self.hideturtle()
        self.penup()
        self.goto(0,270)
        self.update_score()

    def update_score(self):
        self.clear()
        self.write(f"Score: {self.score} High Score: {self.high_score}",align="center",font=("Courier",24,'normal'))

    def reset(self):
        if self.score > self.high_score:
            self.high_score=self.score    
        self.score = 0
        with open("data.txt",'w') as data:
            data.write(f"{self.high_score}")
        self.update_score()


    # def gameOver(self):
    #     self.goto(0,0)
    #     self.color("red")
    #     self.write(f"Game Over", align="center", font=("Courier",28,'normal'))

    def increase_score(self):
        self.score+=1
        self.update_score()
