You need to sign in or sign up before continuing.
Newer
Older
## @file interface.py
# @author Vaibhav Chadha
# @brief implements the main interface of this game
x = 10
y = 40
import os
os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (x,y)
## @brief A Class that will contain useful functions in order for the creation of main interface
## @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)
def custom_text(text,fontName,fontSize,color,coord,surface):
font = pygame.font.Font(fontName,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
lightBlue = [89,131,145]
image1 = pygame.image.load("Images/Snake_Game_Logo_background.png")
image2 = pygame.image.load("Images/Snake_image.png")
mousepos = pygame.mouse.get_pos() #checking mouse position
mouseclick = pygame.mouse.get_pressed()#checking mouse pressed
pygame.display.set_caption("Lets Play")
GUI.custom_text('Beginner',"Roboto-Light.ttf", 25,[239, 245, 224],(438,260),game)
GUI.custom_text('Intermediate',"Roboto-Light.ttf", 25,[239, 245, 224],(470,357),game)
GUI.custom_text('Advanced',"Roboto-Light.ttf", 25,[239, 245, 224],(435,457),game)
if (365 <= mousepos[0] <= 365+55 and 565 <= mousepos[1] <= 565+35 ):
if mouseclick[0] == 1:
help_.main()
GUI.custom_text('Help',"Roboto-Light.ttf", 25,[0,0,0],(365,565),game)
highscore.main()
if (725 <= mousepos[0] <= 725+50 and 565 <= mousepos[1] <= 565+35 ):
pygame.display.update()
if __name__ == "__main__":
main()