diff --git a/BlankProjectTemplate/src/Gameplay.py b/BlankProjectTemplate/src/Gameplay.py index 7a1d7fb5e712ced9aaf474f5c6b77687ce92f0c6..5197934210f998fc0acaac7350c68998bfb58a8b 100644 --- a/BlankProjectTemplate/src/Gameplay.py +++ b/BlankProjectTemplate/src/Gameplay.py @@ -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]) diff --git a/BlankProjectTemplate/src/Interface.py b/BlankProjectTemplate/src/Interface.py index 041f311248dc9059ae573579437f6b08171cf2a5..caa87093284b6937099f9619495a0254d3263498 100644 --- a/BlankProjectTemplate/src/Interface.py +++ b/BlankProjectTemplate/src/Interface.py @@ -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) diff --git a/BlankProjectTemplate/src/__pycache__/Food.cpython-37.pyc b/BlankProjectTemplate/src/__pycache__/Food.cpython-37.pyc index 9a830c92d74ee361f1368ca26cb0c6d707d95e30..ec566ebd5cc12c0c770e1b2c5e4bfdd7779962e9 100644 Binary files a/BlankProjectTemplate/src/__pycache__/Food.cpython-37.pyc and b/BlankProjectTemplate/src/__pycache__/Food.cpython-37.pyc differ diff --git a/BlankProjectTemplate/src/__pycache__/Gameplay.cpython-37.pyc b/BlankProjectTemplate/src/__pycache__/Gameplay.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5ef139510bee34ec910d8edd8a3c9208b68080df Binary files /dev/null and b/BlankProjectTemplate/src/__pycache__/Gameplay.cpython-37.pyc differ diff --git a/BlankProjectTemplate/src/__pycache__/Interface.cpython-37.pyc b/BlankProjectTemplate/src/__pycache__/Interface.cpython-37.pyc index 9a4a1cd6e2e72b10a4a497a6d54a3e051f42a7ce..cdf91be755451fac4db284c259b8a719f3f58eaa 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__/Snake.cpython-37.pyc b/BlankProjectTemplate/src/__pycache__/Snake.cpython-37.pyc index 64ed5e1ffc62e81f7a69696008571de8734360c2..b5a5fed23cd43852f47011b2efddf58c2d9e9048 100644 Binary files a/BlankProjectTemplate/src/__pycache__/Snake.cpython-37.pyc and b/BlankProjectTemplate/src/__pycache__/Snake.cpython-37.pyc differ diff --git a/BlankProjectTemplate/src/__pycache__/init.cpython-37.pyc b/BlankProjectTemplate/src/__pycache__/init.cpython-37.pyc index 5ef93ec9897c680e94b72d19d335652862a2b13f..cce923f0e289ed3fb9a8cb0638c6cb526bac5e44 100644 Binary files a/BlankProjectTemplate/src/__pycache__/init.cpython-37.pyc and b/BlankProjectTemplate/src/__pycache__/init.cpython-37.pyc differ diff --git a/BlankProjectTemplate/src/__pycache__/theme.cpython-37.pyc b/BlankProjectTemplate/src/__pycache__/theme.cpython-37.pyc index a2134b3fef5b6f94f441b0ef00f771775de7f4c0..1fa157e9e2fc56fcd1c638e9cbd18a947511d05f 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/theme.py b/BlankProjectTemplate/src/theme.py index 41c83a281a435f17e086aafe359fb5fb89601b24..78e1964503a5b6b4a677f016652985ed033b096d 100644 --- a/BlankProjectTemplate/src/theme.py +++ b/BlankProjectTemplate/src/theme.py @@ -1,5 +1,6 @@ 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()