24 May 2011

I fixed it! Better yet, it didn’t even require a major change to how collisions were detected. Just like before, there are four ways to see if there is a block colliding with the player. You can ask the game if there is noBlockAbove, noBlockBelow, noBlockRight, or noBlockLeft. However, I made several changes. For one thing, before now it would only test a single block on the grid*, now it tests 10 blocks in each direction. So, it loops through 10 separate cells on the grid, and if  a cell is occupied, then it does a normal(ish) hittest of making sure the player is not passing that block. If the player is trying to move up, and its y position is higher than the y position of an occupied cell (and its x position is the “same”**) then it won’t be allowed to move. Try to fall through the blocks in this updated prototype:
[game width=”580″ height=”435″ src=”http://flipoutgames.com/wp-content/uploads/2011/05/GravX1.swf” title=”GravX2″ description=”A puzzle platformer with a gravity twist!” flash=”true”/]
Next time: velocity, gravity, damping, and acceleration!
*: For an explanation of the grid, check 1 post ago.
**: As in, the player is actually in the same column as the block. This way it can move up even if it is passing to the right of an occupied cell.