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

Added difficulty

parent 9d88a0f0
No related branches found
No related tags found
No related merge requests found
......@@ -72,36 +72,43 @@ def game(speed, colour, backgroundColour):
y += (size)*snake.direct
else:
x += (size)*snake.direct
#Boundary conditions for snake hitting window edge
if (x < 0 or
y < 0 or
y > screenSize - size or
x > screenSize - size):
pygame.quit() #for now, quit the game when snake hits boundary
if (speed == 100):
if x < 0:
#x = 0
x = screenSize - size
if y < 0:
#y = 0
y = screenSize - size
if y > screenSize - size:
#y = 500 - size
y = 0
if x > screenSize - size:
#x = 500 - size
x = 0
else:
#Boundary conditions for snake hitting window edge
if (x < 0 or
y < 0 or
y > screenSize - size or
x > screenSize - size):
pygame.quit() #for now, quit the game when snake hits boundary
## snake.die()
#---------------------FOR WRAPING SNAKE AROUND WINDOW---------------------
## if x < 0:
## #x = 0
## x = screenSize - size
## if y < 0:
## #y = 0
## y = screenSize - size
## if y > screenSize - size:
## #y = 500 - size
## y = 0
## if x > screenSize - size:
## #x = 500 - size
## x = 0
#-------------------------------------------------
if(abs(x - food_location[0]) < 15 and abs(y - food_location[1]) < 15):
score += 10
if (speed == 100):
score += 5
elif (speed == 70):
score += 7
else:
score += 10
#increment the length by 3 unit every time
snake_length += 3
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
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