fallé
This commit is contained in:
@@ -832,25 +832,29 @@ public class Worm extends GameObject {
|
||||
//===================================================================================
|
||||
|
||||
public void fall() {
|
||||
double[] center = {getLocation().getX(), getLocation().getY()};
|
||||
double heigth = getWorld().getHeight() - getRadius();
|
||||
Coordinate oldLocation = getLocation();
|
||||
double endY = getLocation().getY();
|
||||
if (canFall()) {
|
||||
for (double y = oldLocation.getY(); y <= (getWorld().getHeight() + 1); y--) {
|
||||
if (y >= (getWorld().getHeight() + 1)) {
|
||||
terminate();
|
||||
}
|
||||
for (double y = oldLocation.getY(); y <= heigth; y = y - 0.1) {
|
||||
double[] newLoc = {oldLocation.getX(), y};
|
||||
setLocation(newLoc);
|
||||
if (! canFall()) {
|
||||
endY = y;
|
||||
if (! getWorld().isPassable(newLoc, getRadius())) {
|
||||
setLocation(newLoc);
|
||||
break;
|
||||
}
|
||||
center[1] = y;
|
||||
// for (double i = y; i >= y - 1; i = i - 0.1) {
|
||||
// double[] newLocation = {oldLocation.getX(), i};
|
||||
// if (! getWorld().isPassable(newLocation, getRadius())) {
|
||||
// setLocation(newLocation);
|
||||
// endY = i;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
terminate();
|
||||
}
|
||||
|
||||
long cost = 3 * (long) Math.floor(oldLocation.getY() - endY);
|
||||
long cost = 3 * (long) Math.floor(oldLocation.getY() - getLocation().getY());
|
||||
decreaseHitPoints(cost);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user