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

Added food parameter

parent bfbe5a63
No related branches found
No related tags found
No related merge requests found
......@@ -18,8 +18,8 @@ class Food():
## @brief Draw method uses pygame to draw the food object on the window
# @param location A list which consists the x and y location of the food
def draw_food(self, location):
pygame.draw.rect(win, [245,250,170] , (location[0],location[1], self.size, self.size))
def draw_food(self, food_colour, location):
pygame.draw.rect(win, food_colour , (location[0],location[1], self.size, self.size))
## @brief redraw_food method redraws the food on the screen randomly
# @param x is the location of snake's x-axis head location
......
......@@ -7,7 +7,7 @@ from random import randint
from Snake import *
from Food import *
def game(speed, colour, backgroundColour):
def game(speed, colour,food_colour, backgroundColour):
x = randint(0, grid_length) * size
y = randint(0, grid_length) * size
#defining a list to update snanke's length
......@@ -137,7 +137,7 @@ def game(speed, colour, backgroundColour):
snake_blocks = len(snake_loc)
#Draw food item
food.draw_food(food_location)
food.draw_food(food_colour, food_location)
if snake_blocks > snake_length:
......
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