Gravitation game
To put into practice what you have learned about steering behaviors, we will build a basic game. The player's objective is to collect some pickup items that rotate around different planets placed in the world, while escaping from enemies. The enemies are non-playable characters that seek the playable character and avoid the planets.
We will represent the characters as particle systems, and the final version of the game will look like this:
Basic game objects
As usual, we will define a base class that wraps the access to the CircleShape
attribute with the updated center:
from cocos.cocosnode import CocosNode from cocos.director import director import cocos.collision_model as cm class Actor(CocosNode): def __init__(self, x, y, r): super(Actor, self).__init__() self.position = (x, y) self._cshape = cm.CircleShape(self.position, r) @property def cshape(self): self._cshape.center = eu.Vector2(self.x, self.y) return self...