Skip to content
Snippets Groups Projects
Commit ecb7eecd authored by Hameed Andy's avatar Hameed Andy
Browse files

comments fixed

parent f8a7ce23
No related branches found
No related tags found
No related merge requests found
...@@ -36,16 +36,16 @@ location = [food_x, food_y] ...@@ -36,16 +36,16 @@ location = [food_x, food_y]
##initialize snake ##initialize snake
snake = Snake(size, 0, 20, 0) snake = Snake(size, 0, 20, 0)
food = Food(size) food = Food(size)
#Loop through the events as long as the game is running #Loop through the events as long as the game is running
run = True run = True
while run: while run:
pygame.time.delay(speed) #create a delay to prevent any unwanted behaviour
#delay controls part of speed
pygame.time.delay(speed)
#events are anything that happens from the user
#we loop through the list of events that happen by the user's actions
for event in pygame.event.get(): for event in pygame.event.get():
#Check if the event is a quit command and quit the game if it is
if event.type == pygame.QUIT: if event.type == pygame.QUIT:
run = False run = False
...@@ -80,40 +80,24 @@ while run: ...@@ -80,40 +80,24 @@ while run:
#x = 500 - size #x = 500 - size
x = 0 x = 0
#consumption of food block
#all colors are defined in RGB with Pygame
#consumption of food block
food.redraw_food(x, y, location, screenSize) food.redraw_food(x, y, location, screenSize)
if(abs(x - location[0]) < 15 and abs(y - location[1]) < 15): if(abs(x - location[0]) < 15 and abs(y - location[1]) < 15):
score += 1 score += 1
print(score) print(score)
## --------------------------DELETE --------------------------
#extend length or size depending on the direction of the snake
## if (axis):
## size += 20
## else:
## size += 20
##---------------------------DELETE----------------------------
win.fill(white) win.fill(white)
#Draw food item #Draw food item
food.draw_food(location) food.draw_food(location)
#food.update_score(x,y,location, score) #food.update_score(x,y,location, score)
#Draw snake #Draw snake
snake.draw(x,y) snake.draw(x,y)
#update display
#we have to update the display to see the drawing of our object. Since it does
#not automatically update
pygame.display.update() pygame.display.update()
#Quit the game
pygame.quit() pygame.quit()
...@@ -27,15 +27,5 @@ class Snake(): ...@@ -27,15 +27,5 @@ class Snake():
pygame.draw.rect(win, red , (x,y, self.size, self.size)) pygame.draw.rect(win, red , (x,y, self.size, self.size))
## @brief Snake consumes a food block
## def consume():
##
##class Block():
##
## def __init__(self, width, height):
## self.w = width
## swlf.h = height
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