Acceleration, Friction, and Wrapping

Review

If you ignored your algebra teacher, you gotta be kicking yourself right now. Or maybe you want to go back and kick your algebra teacher for failing to teach you that math could be so FUN! We simulated acceleration and friction.... so how much of a stretch would it be to simutate gravity?

Just so we're clear, my final code looks like this:

Important Formulas

Apply friction to an object moving on the y-axis:

mc._y=ySpeed*yFriction;

Screen wrap an object moving on the y-axis:

if(mc._y>sH){
mc._y=0;
}else if (mc._y<0){
mc._y=sH;
}

 

Self Check for Understanding

Experiment with the yFriction and yAccel variables! What happens when yFriction>1? Have some fun!