Night 3: Gravity

Heavy stuff. Got the object layer to fall, and collide with the solid world layer.

Today I realized that PyTMX does not assign IDs to or load the coordinates for unused tiles. This makes it difficult to render the second frame of, for example, a bad-guy animation, if the level as drawn in Tiled only shows the first frame.

Instead, my game now uses a second Tiled map just for the characters. Each row is a single character and each column is one of the standard frames for characters like run or jump. The tiles, in a shared tileset, also carry properties to hold names like 'Hero', 'Skeleton' etc. (I am using By loading the second 'critters.tmx' in the background, PyTMX gives me coordinates and properties for all the interesting tiles that don't necessarily appear statically in a level.

The game also handles gamepad hotplugging and removal properly, and as an optimization no longer draws tiles that are outside the visible area of the screen.