Skip to content
Snippets Groups Projects
Commit 690b7f13 authored by Hameed Andy's avatar Hameed Andy
Browse files

Colors modularized

parent 7209f080
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
from random import randint from random import randint
from Snake import * from Snake import *
from Food import * from Food import *
from colors import *
import ScoreDisplay import ScoreDisplay
import GUI import GUI
...@@ -14,10 +15,6 @@ def game(speed, colour,food_colour, backgroundColour): ...@@ -14,10 +15,6 @@ def game(speed, colour,food_colour, backgroundColour):
pygame.event.clear() pygame.event.clear()
image = pygame.image.load("Images/barrier.png") image = pygame.image.load("Images/barrier.png")
black1 = (48,47,47)
black = [0,0,0]
white = [255,255,255]
x = randint(0, grid_length) * size x = randint(0, grid_length) * size
y = randint(0, grid_length) * size y = randint(0, grid_length) * size
#defining a list to update snanke's length #defining a list to update snanke's length
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# @author Vaibhav Chadha # @author Vaibhav Chadha
# @brief implements the main interface of this game # @brief implements the main interface of this game
# @date 11/09/2018 # @date 11/09/2018
#importing necessary libraries
x = 10 x = 10
y = 40 y = 40
import os import os
...@@ -11,15 +11,12 @@ os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (x,y) ...@@ -11,15 +11,12 @@ os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (x,y)
import help_, highscore, theme import help_, highscore, theme
import pygame, sys import pygame, sys
import GUI import GUI
from colors import *
## @brief Makes the main interface of this game ## @brief Makes the main interface of this game
# @details This will output the main page of this game by using the class above # @details This will output the main page of this game by using the class above
def main(): def main():
pygame.init() pygame.init()
lightBlue = [89,131,145]
darkgray = [100,100,100]
offwhite = [239, 245, 224]
black = [0,0,0]
image1 = pygame.image.load("Images/Snake_Game_Logo_background.png") image1 = pygame.image.load("Images/Snake_Game_Logo_background.png")
image2 = pygame.image.load("Images/Snake_image.png") image2 = pygame.image.load("Images/Snake_image.png")
......
...@@ -6,10 +6,10 @@ ...@@ -6,10 +6,10 @@
import pygame, sys import pygame, sys
import highscore, Interface, Gameplay import highscore, Interface, Gameplay
import GUI import GUI
from colors import *
def storeScore(score): def storeScore(score):
prevScore = int(highscore.HighScore.findHighScore()) prevScore = int(highscore.HighScore.findHighScore())
#print(prevScore)
if(score > prevScore): if(score > prevScore):
infile = open("highscore.txt", "w") infile = open("highscore.txt", "w")
infile.write(str(score)) infile.write(str(score))
...@@ -18,23 +18,18 @@ def storeScore(score): ...@@ -18,23 +18,18 @@ def storeScore(score):
def display(score,speed, colour,food_colour, backgroundColour): def display(score,speed, colour,food_colour, backgroundColour):
pygame.init() pygame.init()
storeScore(score) storeScore(score)
lightBlue = [89,131,145]
darkgray = [100,100,100]
white = [255,255,255]
image1 = pygame.image.load("Images/Exit_image.png") image1 = pygame.image.load("Images/Exit_image.png")
run = True run = True
while run: while run:
## roboto_font = pygame.font.Font("Roboto-Black.ttf", 35)
mousepos = pygame.mouse.get_pos() #checking mouse position mousepos = pygame.mouse.get_pos() #checking mouse position
mouseclick = pygame.mouse.get_pressed()#checking mouse pressed mouseclick = pygame.mouse.get_pressed()#checking mouse pressed
lastPage = pygame.display.set_mode((500, 500)) lastPage = pygame.display.set_mode((500, 500))
lastPage.blit(image1,(0,0)) lastPage.blit(image1,(0,0))
## lastPage.fill()
GUI.custom_text('Your Score is ' + str(score),"Roboto-Light.ttf", 40,[0, 0, 0],(93,50),lastPage) GUI.custom_text('Your Score is ' + str(score),"Roboto-Light.ttf", 40,black,(93,50),lastPage)
if (150 <= mousepos[0] <= 150+200 and 150 <= mousepos[1] <= 150+60 ): if (150 <= mousepos[0] <= 150+200 and 150 <= mousepos[1] <= 150+60 ):
GUI.button(lastPage,darkgray, [150,150,200,60], 0) GUI.button(lastPage,darkgray, [150,150,200,60], 0)
...@@ -62,5 +57,3 @@ def display(score,speed, colour,food_colour, backgroundColour): ...@@ -62,5 +57,3 @@ def display(score,speed, colour,food_colour, backgroundColour):
GUI.custom_text('Quit',"Roboto-Light.ttf", 25,white,(225,385),lastPage) GUI.custom_text('Quit',"Roboto-Light.ttf", 25,white,(225,385),lastPage)
pygame.display.update() pygame.display.update()
#display(99)
...@@ -28,10 +28,5 @@ class Snake(): ...@@ -28,10 +28,5 @@ class Snake():
pygame.draw.rect(win, colour , [x,y, self.size, self.size]) pygame.draw.rect(win, colour , [x,y, self.size, self.size])
def die():
#---------------------INSERT CODE -----------------
# create some pop up message saying game over
return
#colors.py
white = (255,255,255)
red = (255,0,0)
black1 = (48,47,47)
white_green = (239,246,224)
blue = (0,0,255)
black = (0,0,0)
lightBlue = (89,131,145)
darkgray = (100,100,100)
offwhite = (239, 245, 224)
lightR = (220,128,128)
lightB = (29,85,145)
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
# @date 11/09/2018 # @date 11/09/2018
import pygame, sys, Interface, pathlib import pygame, sys, Interface, pathlib
import GUI import GUI
from colors import *
## @brief A Class that will contain useful functions in order for the creation of highscore page ## @brief A Class that will contain useful functions in order for the creation of highscore page
class HighScore(): class HighScore():
...@@ -29,9 +30,6 @@ class HighScore(): ...@@ -29,9 +30,6 @@ class HighScore():
# which can be seen by executing this function. # which can be seen by executing this function.
def main(): def main():
pygame.init() pygame.init()
red = [255,0,0]
white = (255,255,255)
black = (48,47,47)
while True: while True:
mousepos = pygame.mouse.get_pos() #checking mouse position mousepos = pygame.mouse.get_pos() #checking mouse position
mouseclick = pygame.mouse.get_pressed()#checking mouse pressed mouseclick = pygame.mouse.get_pressed()#checking mouse pressed
......
...@@ -12,18 +12,6 @@ screenSize = 500 ...@@ -12,18 +12,6 @@ screenSize = 500
win = pygame.display.set_mode((screenSize,screenSize)) win = pygame.display.set_mode((screenSize,screenSize))
pygame.display.set_caption("Snake") pygame.display.set_caption("Snake")
#Define color constants
white = (255,255,255)
red = (255,0,0)
black1 = (1,22,30)
white_green = (239,246,224)
blue = (0,0,255)
black = (0,0,0)
lightBlue = (89,131,145)
darkgray = (100,100,100)
offwhite = (239, 245, 224)
# One size for all blocks created for snake # One size for all blocks created for snake
size = 20 size = 20
grid_length = screenSize/size grid_length = screenSize/size
......
import pygame, sys
from random import randint from random import randint
from colors import *
import pygame, sys
import Gameplay import Gameplay
import init import init
import GUI import GUI
...@@ -16,18 +17,11 @@ class Themes(): ...@@ -16,18 +17,11 @@ class Themes():
exec(rnf.read()) exec(rnf.read())
def themes(speed): def themes(speed):
lightBlue = (89,131,146)
black1 = (48,47,47)
white_green = (239,246,224)
white = (255,255,255)
lightR = [220,128,128]
lightB = [29,85,145]
pygame.init() pygame.init()
run = True run = True
while run: while run:
theme = pygame.display.set_mode((500, 500)) theme = pygame.display.set_mode((500, 500))
theme.fill(white_green) theme.fill(offwhite)
mousepos = pygame.mouse.get_pos() #checking mouse position mousepos = pygame.mouse.get_pos() #checking mouse position
mouseclick = pygame.mouse.get_pressed()#checking mouse pressed mouseclick = pygame.mouse.get_pressed()#checking mouse pressed
pygame.display.set_caption("Snake 2.o") pygame.display.set_caption("Snake 2.o")
...@@ -35,7 +29,7 @@ class Themes(): ...@@ -35,7 +29,7 @@ class Themes():
GUI.custom_text('Choose Your Theme',"Roboto-Light.ttf",45,[96,96,96],(70,50),theme) GUI.custom_text('Choose Your Theme',"Roboto-Light.ttf",45,[96,96,96],(70,50),theme)
GUI.button(theme,lightBlue, [75,150,150,100], 0) GUI.button(theme,lightBlue, [75,150,150,100], 0)
GUI.custom_text('Regular',"Roboto-Light.ttf", 30,white_green,(95,180),theme) GUI.custom_text('Regular',"Roboto-Light.ttf", 30,offwhite,(95,180),theme)
if (75 <= mousepos[0] <= 75+150 and 150 <= mousepos[1] <= 150+100 ): if (75 <= mousepos[0] <= 75+150 and 150 <= mousepos[1] <= 150+100 ):
if mouseclick[0] == 1: if mouseclick[0] == 1:
Gameplay.game(speed, lightB,lightR, white) Gameplay.game(speed, lightB,lightR, white)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment