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

The scenario definition

Once we have loaded the tile map, we need to link the resulting image with the game information. Our scenario class should contain the following:

  • The positions where the turrets can be placed
  • The position of the bunker
  • The initial position for enemy spawning
  • The path that the enemies must follow to reach the bunker

In the following screenshot, we can see this data overlaid on top of our TMX map:

The scenario definition

The rectangles represent the slots in which the player can place the turrets. The scenario stores only the centers of these squares, because the game layer will translate these positions into clickable squares.

The lines over the road represent ...

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