tokumaru wrote:
BTW, players should be able to move up through air... don't characters jump in your game? =)
Actually, I got sick of re-writing the engine over and over so I've attempted to go with a table based approach. Unfortunately I think this has limitations too, but I wont know till I hit them.
My player has a number of player states
STANDING
JUMPING
FALLING
CLIMBING
And I have 3 different object types
SOLID
AIR
STAIRS
And I have 4 different directions (up, down, left, right)
So I make 4 tables (one per state) with 3 rows (one per object type) and 4 entries per row (one per direction)
Then whenever I need to process an interaction, I can check to see if its valid, and what state my player should convert to.
As an example:
; Standing:
;Solid-> up, down, left, right would be: INVALID, INVALID, INVALID, INVALID
;Air- > up, down, left, right would be: INVALID, FALLING, STANDING, STANDING
;Stairs->up,down,left,right would be: CLIMBING, CLIMBING, CLIMBING, CLIMBING
But jumping and falling would behave differently.
Also, this allows me to add a new state (like ghost) where solids dont block me moving left and right (but maybe they do block me travelling up and down so I dont fall off the screen)
I dont know if this approach is good or not, because "invalid" is a sticky case that muddies up the cleanliness of the code. If I'm jumping and hit a solid, I need to transition to falling, etc.. I'm getting around this at the moment by using an "invalid" table but I dont like it.
Al