Skip to content
Snippets Groups Projects
Commit d105e63b authored by 's avatar
Browse files

linking game

parent 611a64cd
No related branches found
No related tags found
No related merge requests found
......@@ -7,14 +7,14 @@ from random import randint
from Snake import *
from Food import *
def Gameplay(speed, colour, backgroundColour):
def game(speed, colour, backgroundColour):
x = randint(0, grid_length) * size
y = randint(0, grid_length) * size
#defining a list to update snanke's length
snake_loc = []
#variable to increment snake's length, initially it would be 1
snake_length = 1
speed = 70
# 0 gives (- direction)
# 1 gives (+ direction)
direction = 1
......@@ -110,7 +110,7 @@ def Gameplay(speed, colour, backgroundColour):
win.fill(backgroundColour)
font = pygame.font.SysFont("times",30)
text = font.render("Score = " + str(score),True,[0,0,0])
text = font.render("Score = " + str(score),True,[50,250,50])
win.blit(text,(0,0))
if ([x,y] in snake_loc) and snake_length > 1:
......@@ -149,3 +149,5 @@ def Gameplay(speed, colour, backgroundColour):
pygame.display.update()
pygame.quit()
#game(70, [255,0,0], [255,255,255])
......@@ -55,7 +55,7 @@ def main():
GUI.button(game,darkgray, [400,250,170,50], 0)
#checking if the button is clicked
if mouseclick[0] == 1:
theme.Themes.themes()
theme.Themes.themes(100)
else:
GUI.button(game,lightBlue, [400,250,170,50], 0)
GUI.text('Beginner',"maiandragd", 25,[239, 245, 224],(438,260),game)
......@@ -65,7 +65,7 @@ def main():
GUI.button(game,darkgray, [430,350,220,50], 0)
#checking if the button is clicked
if mouseclick[0] == 1:
theme.Themes.themes()
theme.Themes.themes(70)
else:
GUI.button(game,lightBlue, [430,350,220,50], 0)
GUI.text('Intermediate',"maiandragd", 25,[239, 245, 224],(470,357),game)
......@@ -75,7 +75,7 @@ def main():
GUI.button(game,darkgray, [400,450,180,50], 0)
#checking if the button is clicked
if mouseclick[0] == 1:
theme.Themes.themes()
theme.Themes.themes(50)
else:
GUI.button(game,lightBlue, [400,450,180,50], 0)
GUI.text('Advanced',"maiandragd", 25,[239, 245, 224],(435,457),game)
......
No preview for this file type
File added
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
import pygame, sys
from random import randint
import Gameplay
class Themes():
......@@ -32,7 +33,7 @@ class Themes():
text = font.render(text,True,color)
surface.blit(text,coord)
def themes():
def themes(speed):
pygame.init()
run = True
while run:
......@@ -48,13 +49,13 @@ class Themes():
Themes.text('Regular',"comicsansms", 40,[200, 0, 0],(80,170),theme)
if (75 <= mousepos[0] <= 75+150 and 150 <= mousepos[1] <= 150+100 ):
if mouseclick[0] == 1:
Themes.runfile('Gameplay.py')
Gameplay.game(speed,[255,0,0],[255,255,255])
Themes.button(theme,[0,0,0], [280,150,150,100], 0)
Themes.text('Dark',"comicsansms", 40,[225,255,255],(305,170),theme)
if (280 <= mousepos[0] <= 280+150 and 150 <= mousepos[1] <= 150+100 ):
if mouseclick[0] == 1:
Themes.runfile('Gameplay.py')
Gameplay.game(speed,[255,255,255],[10,10,10])
Themes.button(theme,[0,0,0], [175,300,80,50], 0)
Themes.button(theme,[200,200,200], [175,350,80,50], 0)
......@@ -64,8 +65,8 @@ class Themes():
if (180 <= mousepos[0] <= 180+160 and 315 <= mousepos[1] <= 315+100 ):
if mouseclick[0] == 1:
x = randint(0, 1)
if(x == 1): Themes.runfile('Gameplay.py')
else: Themes.runfile('Gameplay.py')
if(x == 1): Gameplay.game(speed,[255,0,0],[255,255,255])
else: Gameplay.game(speed,[255,255,255],[10,10,10])
pygame.display.update()
......
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