PDA

View Full Version : [AS2/3] Platform Slopes



Nick23
June 23rd, 2009, 11:22 AM
Hello, I am trying to make a code for platform slopes...

Here is what I have:

//Slope Amendment

if (_root.slope.hitTest(_x+1+8+6,_y-10,true) ||
_root.slope.hitTest(_x-1-8-6,_y-10,true)){falling = false; airtime = 0;}

looptimes = 0; //with loop breaker
if (!_root.slope.hitTest(_x+1+8+6+10,_y-70,true)){
while (_root.slope.hitTest(_x+1+8+6,_y-10-1,true)){_y -= 1;
looptimes+=1; if (looptimes>maxloop){breakcode=true; break;}}
} else rightspeed=0;
trace(looptimes);
looptimes = 0;
if (!_root.slope.hitTest(_x-1-8-6-10,_y-70,true)){
while (_root.slope.hitTest(_x-1-8-6,_y-10-1,true)){_y -= 1;
looptimes+=1; if (looptimes>maxloop){breakcode=true; break;}}
} else leftspeed=0;You can move up and down the slopes just fine, but the problem is (when you are about halfway up a slope) you can't jump/jump slightly into the air.

The code works fine if you swap out the while loops for if statements, but obviously then the player will rise from the slopes and it would just look stupid.

Any ideas?
Thanks!

-Nick

SparK_BR
June 23rd, 2009, 11:37 AM
hmm... check collision with the ground 1 pixel down?
then try to let player jump when 1 close to the ground and not exactly on it...