To keep the character from sinking into the ground, I would run a while loop on every act that checks if the character is sunken and if so, raises the character 1 pixel. You can do similarly in all 4 directions. Be sure to use a while loop, not an if statement: with the while loop, the character will just fall and land perfectly right away, with the if he will slowly rise out of the floor frame by frame instead.
I haven't tried this, but I guess you can loop-increment the position 1 by 1 too, this might keep the character from flying right through the floor when falling fast:
while((int) y > getY() && !hitFloor) {
setLocation(getX(), getY()+1);
}
while((int) y < getY() && !hitHead) {
setLocation(getX(), getY()-1);
}
Instead of
setLocation(getX(), (int) y);
2009/11/21
Archerman
2009/11/21
Archerman
2009/11/21
Archerman
2009/11/21
Archerman
2009/11/21
Archerman
2009/11/19
MonsterHunter
2009/11/19
SimuPark
2009/11/18
Archerman
2009/11/18
Global Men