O'Reilly logo

Python Game Programming By Example by Joseph Howse, Alejandro Rodas de Paz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

Gravitation game

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required