This site requires JavaScript, please enable it in your browser!
Greenfoot
Username
Password
Remember Me?
Sign Up, Lost Password
Activity
About
Documentation
Download
Discuss
Scenarios
student1's Comments
Back to student1's profile
student1
2018/4/2
Dungeon Escape
this is the gravity code i'm using
student1
2018/4/2
Dungeon Escape
public void Gravity() { int groundLevel = getWorld().getHeight() - getImage().getHeight()/2; boolean onGround = (getY() == groundLevel); if (!onGround) { ySpeed++; setLocation(getX(), getY()+ySpeed); if (getY()>=groundLevel) { setLocation(getX(), groundLevel); Greenfoot.getKey(); } } else { if ("space".equals(Greenfoot.getKey())) { ySpeed = -15; setLocation(getX(), getY()+ySpeed); } } }
student1
2018/4/2
Dungeon Escape
danpost, i'm making a game for my college and i'm using code that enables gravity and i'm wandering how you got it so the player does not go through the blocks
X
2018/4/2
Dungeon Escape
2018/4/2
Dungeon Escape
2018/4/2
Dungeon Escape