Developing PyPlatformer
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.
Creating the platforms
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))
Adding pickups
In platformer games, it is common that the player is able to collect some items that give valuable resources. In our game, when the character hits one of these pickups, its ammo is incremented by five units.
To decorate this type of game...