Game ClassesΒΆ

The game classes provide functionality for a simple animated game. They provide the base classes for the view and primary controller. The view, GView, need never be subclassed and can be used as-is (as an attribute of GameApp).

On the other hand, GameApp must be subclassed to provide your game functionality. In particular, your subclass must override the following methods.

init: Called at the start of the game to initialize your program. It is better to put start-up code here rather than in your constructor, because Kivy handles constructors in an unusual way.

update: Called every animation frame (typically 60x a second). This is where you add any code that must update attributes or models.

draw: Called every animation frame (typically 60x a second). This is where you draw all your models. Assuming that your models are all subclasses of GObject, simply loop over all the model objects and call the draw method.

Both of these classes are provided by the game2d module.

Information about geometry (for physics and collision detection) and drawing shapes is documented in the section on Graphics Objects. In addition, the Class Sound provides information about how to handle sound effects in your game.

Contents:

Previous topic

Documentation for A7: Breakout

Next topic

Class GView

This Page