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

code

parent 23bd47ef
No related branches found
No related tags found
No related merge requests found
...@@ -95,7 +95,7 @@ def game(speed, colour,food_colour, backgroundColour): ...@@ -95,7 +95,7 @@ def game(speed, colour,food_colour, backgroundColour):
y > screenSize - size or y > screenSize - size or
x > screenSize - size): x > screenSize - size):
ScoreDisplay.display(score) ScoreDisplay.display(score,speed, colour,food_colour, backgroundColour)
#pygame.quit() #for now, quit the game when snake hits boundary #pygame.quit() #for now, quit the game when snake hits boundary
## snake.die() ## snake.die()
...@@ -125,7 +125,7 @@ def game(speed, colour,food_colour, backgroundColour): ...@@ -125,7 +125,7 @@ def game(speed, colour,food_colour, backgroundColour):
if ([x,y] in snake_loc) and snake_length > 1: if ([x,y] in snake_loc) and snake_length > 1:
pygame.time.delay(1000) pygame.time.delay(1000)
# pygame.quit() #quit for now, but should return to main menu # pygame.quit() #quit for now, but should return to main menu
ScoreDisplay.display(score) ScoreDisplay.display(score,speed, colour,food_colour, backgroundColour)
snake_head = [] snake_head = []
snake_head.append(x) snake_head.append(x)
......
...@@ -37,14 +37,14 @@ def main(): ...@@ -37,14 +37,14 @@ def main():
lightBlue = [89,131,145] lightBlue = [89,131,145]
darkgray = [100,100,100] darkgray = [100,100,100]
image1 = pygame.image.load("Snake_Game_Logo_background.png") image1 = pygame.image.load("Snake_Game_Logo_background.png")
## image2 = pygame.image.load("snake_image.png") image2 = pygame.image.load("Snake_image.png")
#while loop required to always refresh the page #while loop required to always refresh the page
run = True run = True
while run: while run:
game = pygame.display.set_mode((800, 610)) game = pygame.display.set_mode((800, 610))
game.blit(image1,(0,0)) game.blit(image1,(0,0))
## game.blit(image2,(550,0)) game.blit(image2,(550,0))
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("Lets Play") pygame.display.set_caption("Lets Play")
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# @date 11/22/2018 # @date 11/22/2018
import pygame, sys import pygame, sys
import highscore, Interface import highscore, Interface, Gameplay
def storeScore(score): def storeScore(score):
prevScore = int(highscore.HighScore.findHighScore()) prevScore = int(highscore.HighScore.findHighScore())
...@@ -14,7 +14,7 @@ def storeScore(score): ...@@ -14,7 +14,7 @@ def storeScore(score):
infile.write(str(score)) infile.write(str(score))
else: return else: return
def display(score): def display(score,speed, colour,food_colour, backgroundColour):
pygame.init() pygame.init()
storeScore(score) storeScore(score)
run = True run = True
...@@ -22,28 +22,35 @@ def display(score): ...@@ -22,28 +22,35 @@ def display(score):
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((400, 400)) lastPage = pygame.display.set_mode((500, 500))
lastPage.fill([200,150,100]) lastPage.fill([200,150,100])
highscore.HighScore.text('WOAHH Your Score is ' + str(score),"comicsansms", 30,[0, 200, 200],(10,50),lastPage) highscore.HighScore.text('WOAHH Your Score is ' + str(score),"comicsansms", 30,[0, 200, 200],(70,50),lastPage)
if (100 <= mousepos[0] <= 100+200 and 150 <= mousepos[1] <= 150+60 ): if (150 <= mousepos[0] <= 150+200 and 150 <= mousepos[1] <= 150+60 ):
highscore.HighScore.button(lastPage,[0,255,0], [100,150,200,60], 0) highscore.HighScore.button(lastPage,[0,255,0], [150,150,200,60], 0)
if mouseclick[0] == 1: if mouseclick[0] == 1:
Interface.main() Gameplay.game(speed, colour,food_colour, backgroundColour)
else: else:
highscore.HighScore.button(lastPage,[0,170,0], [100,150,200,60], 0) highscore.HighScore.button(lastPage,[0,170,0], [150,150,200,60], 0)
highscore.HighScore.text('PLAY MORE!',"comicsansms", 30,[0,0,0],(110,160),lastPage) highscore.HighScore.text('PLAY AGAIN',"comicsansms", 30,[0,0,0],(160,160),lastPage)
if (100 <= mousepos[0] <= 100+200 and 260 <= mousepos[1] <= 260+60 ): if (150 <= mousepos[0] <= 150+200 and 260 <= mousepos[1] <= 260+60 ):
highscore.HighScore.button(lastPage,[250,0,0], [100,260,200,60], 0) highscore.HighScore.button(lastPage,[0,0,255], [150,260,200,60], 0)
if mouseclick[0] == 1:
Interface.main()
else:
highscore.HighScore.button(lastPage,[0,0,170], [150,260,200,60], 0)
highscore.HighScore.text('MAIN MENU',"comicsansms", 30,[0,0,0],(160,270),lastPage)
if (150 <= mousepos[0] <= 150+200 and 370 <= mousepos[1] <= 370+60 ):
highscore.HighScore.button(lastPage,[250,0,0], [150,370,200,60], 0)
if mouseclick[0] == 1: if mouseclick[0] == 1:
pygame.quit() pygame.quit()
sys.exit() sys.exit()
else: else:
highscore.HighScore.button(lastPage,[170,0,0], [100,260,200,60], 0) highscore.HighScore.button(lastPage,[170,0,0], [150,370,200,60], 0)
highscore.HighScore.text('CAN\'T PLAY',"comicsansms", 30,[0,0,0],(110,270),lastPage) highscore.HighScore.text('CAN\'T PLAY',"comicsansms", 30,[0,0,0],(160,380),lastPage)
pygame.display.update() pygame.display.update()
......
BlankProjectTemplate/src/Snake_image.png

37.2 KiB

No preview for this file type
No preview for this file type
No preview for this file type
20 42
\ No newline at end of file \ No newline at end of file
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