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

added comments

parent 2bb10026
No related branches found
No related tags found
No related merge requests found
......@@ -16,9 +16,9 @@ vel = 10
global a
a = 0
#defining a list to keep track of snake's head
snake_loc = []
#defining a list to update snanke's length
snake_loc = []
#variable to increment snake's length, initially it would be 1
snake_length = 1
......@@ -96,7 +96,9 @@ while run:
if(abs(x - food_location[0]) < 15 and abs(y - food_location[1]) < 15):
score += 10
print(score)
snake_length += 5
#increment the length by 3 unit every time
snake_length += 3
......@@ -105,27 +107,34 @@ while run:
#consumption of food block
food.redraw_food(x, y, food_location, screenSize)
snake_top = []
snake_top.append(x)
snake_top.append(y)
snake_loc.append(snake_top)
snake_head = []
snake_head.append(x)
snake_head.append(y)
snake_loc.append(snake_head)
snake_blocks = len(snake_loc)
#Draw food item
food.draw_food(food_location)
if (len(snake_loc)) > snake_length:
if snake_blocks > snake_length:
#keep updating the new block
del snake_loc[0]
'''
Logic for updating the length is taken from:
CodeWithHarry, CodeWithHarry. “Snakes Game: Length Increment Logic - Python Game Development Using Pygame In Hindi #17.”
YouTube, YouTube, 2 Oct. 2018,
www.youtube.com/watch?v=mkGJb0W03DM&index=17&list=PLu0W_9lII9ailUQcxEPZrWgDoL36BtPYb.
'''
#food.update_score(x,y,food_location, score)
#Draw snake
snake.draw(snake_loc)
#update display
pygame.display.update()
print(snake_head, '\n')
print(snake_loc)
pygame.quit()
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