From 2fc2cf1d49a357122c6a52ed617dea253fa2c6df Mon Sep 17 00:00:00 2001 From: <vc2310@LAPTOP-FCB0H0KM.localdomain> Date: Fri, 9 Nov 2018 22:46:20 -0500 Subject: [PATCH] updating src --- BlankProjectTemplate/src/Interface.py | 27 +++++++++++++++++++-- BlankProjectTemplate/src/highscore.py | 34 ++++++++++++++++++++++++--- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/BlankProjectTemplate/src/Interface.py b/BlankProjectTemplate/src/Interface.py index 546aa50..06665ba 100644 --- a/BlankProjectTemplate/src/Interface.py +++ b/BlankProjectTemplate/src/Interface.py @@ -1,21 +1,44 @@ +## @file interface.py +# @author Vaibhav Chadha +# @brief implements the main interface of this game +# @date 11/11/2018 #importing necessary libraries import pygame, sys import highscore +## @brief A Class that will contain useful functions in order for the creation of main interface class GUI(): - #a function made to execute other files from the system + + ## @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 + # @param surface The background (surface) the box should be made on + # @param color The color of the button to be made + # @param Rect The coordinate of the button with the length and width + # @param width The width of the sides of button def button(Surface, color,Rect,width): pygame.draw.rect(Surface, color,Rect,width) + ## @brief A method to display text + # @details This function will print the text on the interface + # @param text The text to be printed + # @param fontStyle The font Style of the text to be displayed + # @param fontSize The size of the text written + # @param color The color of the text + # @param coord The coordinate at which the text should start displaying + # @param surface The background (surface) the text should be printed on def text(text,fontStyle,fontSize,color,coord,surface): font = pygame.font.SysFont(fontStyle,fontSize) text = font.render(text,True,color) surface.blit(text,coord) - +## @brief Makes the main interface of this game +# @details This will output the main page of this game by using the class above def main(): pygame.init() gray = [180,180,180] diff --git a/BlankProjectTemplate/src/highscore.py b/BlankProjectTemplate/src/highscore.py index 8cd06be..5645818 100644 --- a/BlankProjectTemplate/src/highscore.py +++ b/BlankProjectTemplate/src/highscore.py @@ -1,18 +1,44 @@ +## @file highscore.py +# @author Vaibhav Chadha +# @brief implements the highscore interface +# @date 10/11/2018 import pygame, sys +## @brief A Class that will contain useful functions in order for the creation of highscore page class HighScore(): + + + ## @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 display text + # @details This function will print the text on the interface + # @param text The text to be printed + # @param fontStyle The font Style of the text to be displayed + # @param fontSize The size of the text written + # @param color The color of the text + # @param coord The coordinate at which the text should start displaying + # @param surface The background (surface) the text should be printed on def text(text,fontStyle,fontSize,color,coord,surface): font = pygame.font.SysFont(fontStyle,fontSize) text = font.render(text,True,color) surface.blit(text,coord) + ## @brief A method to create a button + # @details This method will make a box on the interface + # @param surface The background (surface) the box should be made on + # @param color The color of the button to be made + # @param Rect The coordinate of the button with the length and width + # @param width The width of the sides of button def button(Surface, color,Rect,width): pygame.draw.rect(Surface, color,Rect,width) + ## @brief Finds the highest score from the file + # @details This writes the input from the file in an array and find the max number from it def findHighscore(): infile = open("highscore.txt","r") mylist = [] @@ -20,7 +46,9 @@ class HighScore(): a = line.strip() mylist.append(a) return max(mylist) - +## @brief Makes the highscore interface +# @details This will output the final interface using the class above +# which can be seen by executing this function. def main(): pygame.init() red = [255,0,0] @@ -37,8 +65,8 @@ def main(): HighScore.text('Main Menu',"times", 25,red,(90,70),highscore) if (90 <= mousepos[0] <= 90+120 and 70 <= mousepos[1] <= 70+27 ): if mouseclick[0] == 1: - #HighScore.runfile('Snake_Game.py') - Snake_Game.main() + HighScore.runfile('Interface.py') + #Snake_Game.main() HighScore.button(highscore,[0,0,0], [125,105,45,27], 0) HighScore.text('Quit',"times", 25,red,(125,105),highscore) -- GitLab