Skip to content
Snippets Groups Projects
Commit 9d705541 authored by Hameed Andy's avatar Hameed Andy
Browse files
parents 997eb9c1 cc0a14dd
No related branches found
No related tags found
No related merge requests found
......@@ -97,7 +97,7 @@ def game(speed, colour,food_colour, backgroundColour):
y > screenSize - size or
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
## snake.die()
......@@ -127,7 +127,7 @@ def game(speed, colour,food_colour, backgroundColour):
if ([x,y] in snake_loc) and snake_length > 1:
pygame.time.delay(1000)
# 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.append(x)
......
......@@ -37,14 +37,14 @@ def main():
lightBlue = [89,131,145]
darkgray = [100,100,100]
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
run = True
while run:
game = pygame.display.set_mode((800, 610))
game.blit(image1,(0,0))
## game.blit(image2,(550,0))
game.blit(image2,(550,0))
mousepos = pygame.mouse.get_pos() #checking mouse position
mouseclick = pygame.mouse.get_pressed()#checking mouse pressed
pygame.display.set_caption("Lets Play")
......
......@@ -4,7 +4,7 @@
# @date 11/22/2018
import pygame, sys
import highscore, Interface
import highscore, Interface, Gameplay
def storeScore(score):
prevScore = int(highscore.HighScore.findHighScore())
......@@ -14,7 +14,7 @@ def storeScore(score):
infile.write(str(score))
else: return
def display(score):
def display(score,speed, colour,food_colour, backgroundColour):
pygame.init()
storeScore(score)
run = True
......@@ -22,28 +22,35 @@ def display(score):
mousepos = pygame.mouse.get_pos() #checking mouse position
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])
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", 35,[0, 200, 200],(40,50),lastPage)
if (100 <= mousepos[0] <= 100+200 and 150 <= mousepos[1] <= 150+60 ):
highscore.HighScore.button(lastPage,[0,255,0], [100,150,200,60], 0)
if (150 <= mousepos[0] <= 150+200 and 150 <= mousepos[1] <= 150+60 ):
highscore.HighScore.button(lastPage,[0,255,0], [150,150,200,60], 0)
if mouseclick[0] == 1:
Interface.main()
Gameplay.game(speed, colour,food_colour, backgroundColour)
else:
highscore.HighScore.button(lastPage,[0,170,0], [100,150,200,60], 0)
highscore.HighScore.text('PLAY MORE!',"comicsansms", 30,[0,0,0],(110,160),lastPage)
highscore.HighScore.button(lastPage,[0,170,0], [150,150,200,60], 0)
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 ):
highscore.HighScore.button(lastPage,[250,0,0], [100,260,200,60], 0)
if (150 <= mousepos[0] <= 150+200 and 260 <= mousepos[1] <= 260+60 ):
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:
pygame.quit()
sys.exit()
else:
highscore.HighScore.button(lastPage,[170,0,0], [100,260,200,60], 0)
highscore.HighScore.text('CAN\'T PLAY',"comicsansms", 30,[0,0,0],(110,270),lastPage)
highscore.HighScore.button(lastPage,[170,0,0], [150,370,200,60], 0)
highscore.HighScore.text('CAN\'T PLAY',"comicsansms", 30,[0,0,0],(160,380),lastPage)
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
\ No newline at end of file
42
\ 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