This is kind of a strange problem, however in my code I have made it so that there is a physics system where my actor can jump, and when he does he is brought back down until he hits the ledge which is another actor, its pretty simple. However, whenever my actor falls from a high enough height and the veloctiy is high enough, the actor falls somewhat into the ledge (image/actor). This is kind of hard to explain but below is the coding I have for the gravity and jumping. I can also make a video of the problem if that would help. Thanks guys.
and this is the code for jumping
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | public boolean onGround() { Object under = getOneObjectAtOffset( 0 , getImage().getHeight()/ 2 - 2 , Ledge. class ); return under != null ; } public void setVSpeed( int speed) { vSpeed = speed; } public void fall() { setLocation ( getX(), getY() + vSpeed); vSpeed += acceleration; } public void checkFall() { if (onGround()) { vSpeed = 0 ; } else { fall(); } } |
1 2 3 4 | if (Greenfoot.isKeyDown( "space" )) { setLocation (getX(), getY()- 17 ); } |