I programmed a slighty better code (without the gravity/10 thing, that is , 0.1, or even 0.01 increments), and I'm intensely testing it.
I'm using the ApplyMovement approach. Now, 5% of probability of jigging (unknown forces of nature). And if she does so, she will stop jigging in less than 2 seconds.
- Code: Select All Code
//anti gravity. In other words, she touches ground (or are inside it for any reason). Let her higher, until she's right onto the ground
while (_root.ground.hitTest(_x+Peach_setX, _y+Peach_setY, true))
{
Peach_setY--;
}
//if she jumps (positive grav), put her on that height.
if (char.grav<0)
Peach_setY+=char.grav;
//GRAVITY: if grav=0 (equilibrium) or negative grav, check gravity. Do it tenderly (checking ground on every pace).
for (aa=0;aa<char.grav+char.total_gravity;aa++)
{
if (!_root.ground.hitTest(_x+Peach_setX, _y+1+Peach_setY, true))
//+1 is to avoid DEAD LOCK in future frames (shes going down then going up then going down) <-JIG PROBLEM
{
Peach_setY++;
}
else //she hit the ground. Grav will be zero (equilibrium).
{
char.grav=0;
break;
}
}
//
// APPLYMOVEMENT
_x+=Peach_setX;
_y+=Peach_setY;
Peach_setX=0; //reset for the next loop
Peach_setY=0; //reset for the next loop
I can program using trigonometric functions and more advanced hitbox live creation but, really, its not necessary (at least for now) and it will need more testing (sometimes it lasts 2 hours just for testing). It may be necessary for ledge collisions inside water, due to the fact Peach changes her feet and head collision when she's in laid position. I'm doing pace by pace. I just can't halt the creation of new levels and enemies.