Fall methode (nog niet klaar)

This commit is contained in:
Leen Dereu
2018-04-12 13:31:44 +02:00
parent 17ce8566a3
commit 51dbd29285

View File

@@ -818,8 +818,36 @@ public class Worm extends GameObject {
// region falling // region falling
//=================================================================================== //===================================================================================
public void fall() { private void fall() {
double[] center = {getLocation().getCoordinateX(), getLocation().getCoordinateY()};
Coordinate oldLocation = getLocation();
double endY = getLocation().getCoordinateY();
if (! getWorld().isAdjacent(center, minRadius)) {
for (double y = oldLocation.getCoordinateY(); y < 0; y--) {
if (y < 0) {
terminate();
}
if (getWorld().isAdjacent(center, minRadius)) {
double[] newLoc = {oldLocation.getCoordinateX(), y};
setLocation(newLoc);
endY = y;
break;
}
center[1] = y;
}
}
//TODO hitpoints en eventuele botsing
double distanceY = getWorld().getHeight();
long cost = 3 * (long) (oldLocation.getCoordinateY() - endY);
incrementHitPoints(cost);
}
public void collisionFall(Worm fallingWorm, Worm... worm) {
for (Worm stationaryWorm: worm) {
}
} }
//=================================================================================== //===================================================================================