An object oriented demo of a platformer game loading a map from the Tiled Map Editor using PyGame and PyTMX. Graphics from the HTML5 game Biolab Disaster.
Just download and run main.py
, dependencies are Python 3.4, PyGame, and PyTMX.
The basic structure of the game and how it loads the map is as follows..
- A basic game class that has a list of level objects
- The level objects are loaded with a TMX map file, using PyTMX
- Levels contain a list of layer objects, one for each layer in the map
- Each layer has a list of tiles, that is actually a PyGame sprite group
The tile objects are created in the initialiation of each layer. A player is added through the player class and collision is easily detected by checking the sprite collision of whatever layer your map uses for collision.