With this architectural background, we can start crafting the custom components of our platformer game. The Component API may look simple, but it allows us to implement the functionality in a succinct manner.
Each platform of our game is nothing but a cube with a static rigid body. However, since we will create several instances with these components, it is convenient to define a class to avoid repeating this kind of instantiation:
class Platform(GameObject): def __init__(self, x, y, width, height): super(Platform, self).__init__(x, y) color = (0.2, 1, 0.5, 1) self.add_components(Cube(color, size=(width, height, 2)), BoxCollider(width, height))