-
Book Overview & Buying
-
Table Of Contents
Python Game Programming By Example
By :
The Component and GameObject classes form the core of our game engine. The interface offered by the Component class is as easy as this:
class Component(object):
__slots__ = ['gameobject']
def start(self):
pass
def update(self, dt):
pass
def stop(self):
pass
def on_collide(self, other, contacts):
passThese methods define the life cycle of our components:
start(): This is called when the component is added to the game object instance. The component keeps a reference to the game object as self.gameobject.
update(dt): This is called for each frame, where the dt argument is the elapsed time in seconds since the previous frame.
on_collide(other, contacts): This is called when the component's game object collides with another rigid body. The other argument is the other game object of the collision pair, and contacts includes the contact points between the objects. This last argument is directly passed from the Pymunk...
Change the font size
Change margin width
Change background colour