Task 3.3: Create the draw method
- Create a new method called
draw
.
π‘ Hint
- Use the
def
keyword. - It should be written inside your Food class (at the same indentation level as
__init__()
). - This method wonβt take any arguments (only
self
). - This method will draw the food onto the screen.
- In general, a method looks like:
class Car:
# These are our properties
def __init__(self, colour, speed):
colour = colour
speed = speed
β
# These are our methods
def drive(self):
# Do something here
- Draw the Sprite onto the Screen
π‘ Hint
- Use
screen.blit(...)
to draw. Refer to your previous lines of code to see how to use this function! - The first thing you want to draw is the sprite.
- The position to draw at is
(position_x, position_y)
.
π© Checkpoint
- A
draw()
method inside your Player class which knows how to: - Draw the sprite.
- Place it at the correct position.