2010-12-19

2D Platforming Game

Well, I had a dream one day, December 1st or something, where I was instructed how to make a platforming game.
I woke up, coded it, and it worked.
DAMN simple too.

Given a list of AABB's in space, and Actors which contain AABB's for motion against the level,
Simply calculate the current bounds and previous bounds (stored)
then detect any EDGE crossings based on the difference from the previous/current bounds for edges;
Then take the minimum edges found, and move the character out from those edges, with some epsilon (in flash, 0.1 works)

To fire a laser in the game, use a space hash (Make a uniform grid of blocks that store references to the objects) and use a specialized edge traversal algorithm, that moves to the next best slope cell, and check everything in that cell until the laser is exhausted or hits something. Handle the case if it changes a major cell, and check the next two to avoid errors.

Both these ideas work PERFECTLY, and thus any 2D platforming game (without ramps so far) is easily made.

Once I clean up the engine, I'll post it so people can make their own high-powered 2D platformers.

-Z