Skip to content
Snippets Groups Projects
Commit 16c8f567 authored by Usman Irfan's avatar Usman Irfan
Browse files

Added maze

parent cd91727a
No related branches found
No related tags found
No related merge requests found
......@@ -77,7 +77,9 @@ def game(speed, colour,food_colour, backgroundColour):
else:
x += (size)*snake.direct
boundary_condition = (x < 0 or y < 0 or y > screenSize - size or x > screenSize - size)
maze_x = x == 100
maze_y = abs(y - 240) <= 140
if (speed == 100):
if x < 0:
#x = 0
......@@ -91,16 +93,16 @@ def game(speed, colour,food_colour, backgroundColour):
if x > screenSize - size:
#x = 500 - size
x = 0
else:
elif (speed == 70):
#Boundary conditions for snake hitting window edge
if (x < 0 or
y < 0 or
y > screenSize - size or
x > screenSize - size):
if (boundary_condition):
run = False
ScoreDisplay.display(score,speed, colour,food_colour, backgroundColour)
elif (speed == 50):
if (maze_x and maze_y or boundary_condition):
run = False
ScoreDisplay.display(score,speed, colour,food_colour, backgroundColour)
#-------------------------------------------------
......@@ -117,6 +119,11 @@ def game(speed, colour,food_colour, backgroundColour):
win.fill(backgroundColour)
if speed == 50:
if (backgroundColour == black1):
pygame.draw.rect(win, (0,0,255) , [100,100, 20, 300])
else:
pygame.draw.rect(win, (0,255,0) , [100,100, 20, 300])
sc_color = [0,0,0] if backgroundColour[0] == 255 else [255,255,255]
font = pygame.font.Font("Roboto-Light.ttf",30)
text = font.render(" " + str(score),True,sc_color)
......
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