diff --git a/BlankProjectTemplate/src/Interface.py b/BlankProjectTemplate/src/Interface.py index c82c0c2e80c9169aa084bf3d7c95693bc31c31ce..75302d322c67297cb2c665a148c652a8818b2a1f 100644 --- a/BlankProjectTemplate/src/Interface.py +++ b/BlankProjectTemplate/src/Interface.py @@ -8,13 +8,6 @@ import highscore, theme ## @brief A Class that will contain useful functions in order for the creation of main interface class GUI(): - - ## @brief A function for running other files - # @details Executes another python file when this is selected, Given that the file is in same folder. - # @param runfilename The name of the file to be executed - def runfile(runfilename): - with open(runfilename,"r") as rnf: - exec(rnf.read()) ## @brief A method to create a button # @details This method will make a box on the interface @@ -41,70 +34,60 @@ class GUI(): # @details This will output the main page of this game by using the class above def main(): pygame.init() - lightgray = [200,200,200] - gray = [180,180,180] + lightBlue = [200,200,200] darkgray = [100,100,100] - red = [255,0,0] + image1 = pygame.image.load("Snake_Game_Logo_background.png") + image2 = pygame.image.load("snake_image.png") #while loop required to always refresh the page run = True while run: game = pygame.display.set_mode((800, 610)) - game.fill([213, 219, 219]) + game.blit(image1,(0,0)) + game.blit(image2,(550,0)) mousepos = pygame.mouse.get_pos() #checking mouse position mouseclick = pygame.mouse.get_pressed()#checking mouse pressed pygame.display.set_caption("Lets Play") - GUI.text('SNAKE GAME',"monospace", 100,red,(100,80),game) #Adding the play game button - if (130 <= mousepos[0] <= 130+250 and 250 <= mousepos[1] <= 250+100 ): + if (400 <= mousepos[0] <= 400+170 and 250 <= mousepos[1] <= 300+50 ): #checks if the mouse is hovering over the button - GUI.button(game,darkgray, [130,250,250,100], 0) + GUI.button(game,darkgray, [400,250,170,50], 0) #checking if the button is clicked if mouseclick[0] == 1: theme.Themes.themes() else: - GUI.button(game,lightgray, [130,250,250,100], 0) - GUI.text('Beginner',"comicsansms", 40,[10, 200, 10],(170,270),game) + GUI.button(game,lightBlue, [400,250,170,50], 0) + GUI.text('Beginner',"comicsansms", 35,[10, 200, 10],(410,250),game) - if (430 <= mousepos[0] <= 430+250 and 250 <= mousepos[1] <= 250+100 ): + if (430 <= mousepos[0] <= 430+220 and 350 <= mousepos[1] <= 350+50 ): #checks if the mouse is hovering over the button - GUI.button(game,darkgray, [430,250,250,100], 0) + GUI.button(game,darkgray, [430,350,220,50], 0) #checking if the button is clicked if mouseclick[0] == 1: theme.Themes.themes() else: - GUI.button(game,lightgray, [430,250,250,100], 0) - GUI.text('Intermediate',"comicsansms", 40,[250, 250, 10],(431,270),game) + GUI.button(game,lightBlue, [430,350,220,50], 0) + GUI.text('Intermediate',"comicsansms", 35,[250, 250, 10],(430,350),game) - if (270 <= mousepos[0] <= 270+250 and 400 <= mousepos[1] <= 400+100 ): + if (400 <= mousepos[0] <= 400+180 and 450 <= mousepos[1] <= 450+50 ): #checks if the mouse is hovering over the button - GUI.button(game,darkgray, [270,400,250,100], 0) + GUI.button(game,darkgray, [400,450,180,50], 0) #checking if the button is clicked if mouseclick[0] == 1: theme.Themes.themes() else: - GUI.button(game,lightgray, [270,400,250,100], 0) - GUI.text('Advanced',"comicsansms", 40,[200, 10, 30],(300,420),game) + GUI.button(game,lightBlue, [400,450,180,50], 0) + GUI.text('Advanced',"comicsansms", 35,[200, 10, 30],(410,450),game) - #Highest Score - if ( 10 <= mousepos[0] <= 310 and 550 <= mousepos[1] <= 550 +55): - GUI.button(game,[200,0,0],[10,550,300,55], 0) + if (15 <= mousepos[0] <= 15+115 and 565 <= mousepos[1] <= 565+35 ): if mouseclick[0] == 1: - highscore.main() - else: - GUI.button(game,[180,180,180], [10,550,300,55], 0) - GUI.text('HIGHEST SCORE',"comicsansms", 35,[0, 0, 0],(10,550),game) - - #If user wants to quit - if ( 670 <= mousepos[0] <= 670+105 and 550 <= mousepos[1] <= 550 +55): - GUI.button(game,[200,0,0],[670,550,105,55], 0) + highscore.main() + + if (725 <= mousepos[0] <= 725+50 and 565 <= mousepos[1] <= 565+35 ): if mouseclick[0] == 1: - pygame.quit() - sys.exit() - else: - GUI.button(game,[180,180,180], [670,550,105,55], 0) - GUI.text('QUIT',"comicsansms", 35,(0, 0, 0),(670,550),game) + pygame.quit() + sys.exit() pygame.display.update() diff --git a/BlankProjectTemplate/src/Snake_Game_Logo_background.png b/BlankProjectTemplate/src/Snake_Game_Logo_background.png new file mode 100644 index 0000000000000000000000000000000000000000..f7f0eeb47166be8f75f26869294bd64d42d10e01 Binary files /dev/null and b/BlankProjectTemplate/src/Snake_Game_Logo_background.png differ diff --git a/BlankProjectTemplate/src/__pycache__/Interface.cpython-37.pyc b/BlankProjectTemplate/src/__pycache__/Interface.cpython-37.pyc index 8ac82ceaaaff8c2f9af45844d30705cb9cd3d8bc..9a4a1cd6e2e72b10a4a497a6d54a3e051f42a7ce 100644 Binary files a/BlankProjectTemplate/src/__pycache__/Interface.cpython-37.pyc and b/BlankProjectTemplate/src/__pycache__/Interface.cpython-37.pyc differ diff --git a/BlankProjectTemplate/src/__pycache__/theme.cpython-37.pyc b/BlankProjectTemplate/src/__pycache__/theme.cpython-37.pyc index 51083db02c0797c2a6e9d41e244f0793e98ada13..a2134b3fef5b6f94f441b0ef00f771775de7f4c0 100644 Binary files a/BlankProjectTemplate/src/__pycache__/theme.cpython-37.pyc and b/BlankProjectTemplate/src/__pycache__/theme.cpython-37.pyc differ diff --git a/BlankProjectTemplate/src/snake_image.png b/BlankProjectTemplate/src/snake_image.png new file mode 100644 index 0000000000000000000000000000000000000000..cf3f0abe920c8a70740cb103d1b0fa767f0f4a12 Binary files /dev/null and b/BlankProjectTemplate/src/snake_image.png differ