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