## @file ScoreDisplay.py # @author Vaibhav Chadha # @brief implements the interface after the snake dies # @date 11/22/2018 import pygame, sys import highscore, Interface, Gameplay def storeScore(score): prevScore = int(highscore.HighScore.findHighScore()) #print(prevScore) if(score > prevScore): infile = open("highscore.txt", "w") infile.write(str(score)) else: return def display(score,speed, colour,food_colour, backgroundColour): pygame.init() storeScore(score) run = True while run: mousepos = pygame.mouse.get_pos() #checking mouse position mouseclick = pygame.mouse.get_pressed()#checking mouse pressed lastPage = pygame.display.set_mode((500, 500)) lastPage.fill([200,150,100]) highscore.HighScore.text('WOAHH Your Score is ' + str(score),"comicsansms", 35,[0, 200, 200],(40,50),lastPage) if (150 <= mousepos[0] <= 150+200 and 150 <= mousepos[1] <= 150+60 ): highscore.HighScore.button(lastPage,[0,255,0], [150,150,200,60], 0) if mouseclick[0] == 1: Gameplay.game(speed, colour,food_colour, backgroundColour) else: highscore.HighScore.button(lastPage,[0,170,0], [150,150,200,60], 0) highscore.HighScore.text('PLAY AGAIN',"comicsansms", 30,[0,0,0],(160,160),lastPage) if (150 <= mousepos[0] <= 150+200 and 260 <= mousepos[1] <= 260+60 ): highscore.HighScore.button(lastPage,[0,0,255], [150,260,200,60], 0) if mouseclick[0] == 1: Interface.main() else: highscore.HighScore.button(lastPage,[0,0,170], [150,260,200,60], 0) highscore.HighScore.text('MAIN MENU',"comicsansms", 30,[0,0,0],(160,270),lastPage) if (150 <= mousepos[0] <= 150+200 and 370 <= mousepos[1] <= 370+60 ): highscore.HighScore.button(lastPage,[250,0,0], [150,370,200,60], 0) if mouseclick[0] == 1: pygame.quit() sys.exit() else: highscore.HighScore.button(lastPage,[170,0,0], [150,370,200,60], 0) highscore.HighScore.text('CAN\'T PLAY',"comicsansms", 30,[0,0,0],(160,380),lastPage) pygame.display.update() #display(99)