I have been looking around for awhile but I'm not making sense of it. When I use the index I can't find the "applyGravity" code.


1 2 3 4 5 6 7 8 9 | // with a class constant public static final int GRAVITY = 1 ; // gravity constant // and instance field private int vSpeed; // for current vertical speed // then, in act or method it calls vSpeed = vSpeed + GRAVITY; // apply gravity setLocation(getX(), getY()+vSpeed); // move vertically |
1 2 3 4 | if (!getIntersectingObjects(platform. class ).isEmpty()) { move( 0 ); } |
1 2 3 4 5 6 | int dir = ( int )Math.signum(vSpeed); // 1, 0 or -1 (direction of vertical movement) while (isTouching(platform. class )) { setLocation(getX(), getY()-dir); // edging back off the platform vSpeed = 0 ; // kill speed on hitting a platform } |