I've recently gotten into programming using Allegro, and I must say it's pretty cool. I've tried programming a platform engine, but I run into problems similar to when you make a custom platform engine in MMF and don't use MMF and/or Platform Movement Object. I can control my character left and right, he falls down when in the air, and collides with obstacles. But when standing on ground, he "twitches" up and down just like in MMF. Anybody know what to do ?
n/a
Assault Andy Administrator
I make other people create vaporware
Registered 29/07/2002
Points 5686
25th April, 2006 at 08:35:16 -
It probably has something to do with your programming. My theory is that when your player is touching the ground he is pushed up to get him out of the ground, but as soon as he is out of the ground, he is pushed back in because of gravity. You probably need to balance it out somehow.
That's exactly what's happening. I just have no idea how to balance it. I've tried pushing the player up by 2 pixels if he collides, and down by 1 if he doesnt. ALso tried 1 up, 2 down etc. nothing works..
You'll have to figure out a way for the character to be exactly 1 pixel above before the screen is drawn. Lots of things can be done before that happens.
thinking is like pong, it's easy, but you miss sometimes.
Concepts like detectors in MMF carry over to C++. You could experiment with using a zone under the player's feet. You only make him fall if the zone isn't over something, and only raise him if his feet are overlapping.
IF the first row of pixels beneath the player collision box are free from collision
THEN Apply gravity code (increase falling speed or whatever)
ELSE do nothing
Then you move the character according to its vertical and horizontal speed, check for collisions and stuff to find the appropriate position.
That way you won't have to handle a lot of collisions with the ground when just walking left and right, since the gravity code won't run as long as the character is standing on something.