Task 3.1: Create a Player Class
Classes, also known as objects, work like a blueprint. Every class can have properties and methods.
For example, a car class can have the properties colour = red and the methods drive(). Typically we name our class with capital letters, e.g. class Car
or class Bird
.
- Create a
Player
class to store the player’s position, size and image (sprite) - Inside your
Player
class, create an__init__()
method.
💡 Hint
- Generally, you can make a class in Python like so:
class Car:
def __init__(self, colour, speed):
colour = colour
speed = speed
🚩 Checkpoint
- A
Player
class - An
__init__()
method inside the class - Player properties:
position_x
position_y
size
image
sprite