Two things that I can think of that might help are
1. Track the trend. Use some variables to track which way the actor is moving, or has been moving. If the actor is heading up(jump), and the player presses down... too bad. you are going up, at least for a little while.
- Code: Select all
// actor variables
int YTrend;
int MoldY;
int SmellY;
int CrustY;
// each draw, or keypress or whatever..
CrustY = SmellY;
SmellY = MoldY;
YTrend = y-CrustY - SmellY - MoldY;
MoldY = y; // Do this one After the YTrend to set it for next draw
// Decide what to do based on the trend.
// Something like this anyway. You could use directional_velocity as well.
The resultant number should indicate which way the actor has been heading for the last few draws.
The second method is that if collision is not working... get rid of the collision. When the player enters an area, near some platforms, have him pass and silently trip a collision with a filled actor that sets some variables indicating the heights of the nearest platforms. Then you manually check the actors height compared to those variables and decide what to do.
This is probably more intuitive overall, and gives you more exact control.
An interesting third thing to investigate would be to not have player controls at all; Keys are bound to an area, so that when the players actor is within visibility(colliding) the area remotely controls the actions of the actor, allowing area specific effects.
Lately, I have been considering friction. I think thats easiest of all, overall, but I dont have anything to say on it as of yet.
The problem from my perspective is that past actions have no effect on current actions. You need to accomodate that. IF they are heading down, they simply cannot start heading up again. Remove the collision detection out of the realm of the key press.