From 51dbd29285e13af55f6353687780f1e6e6fdd285 Mon Sep 17 00:00:00 2001 From: Leen Dereu Date: Thu, 12 Apr 2018 13:31:44 +0200 Subject: [PATCH] Fall methode (nog niet klaar) --- OGP1718-Worms/src/worms/model/Worm.java | 30 ++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/OGP1718-Worms/src/worms/model/Worm.java b/OGP1718-Worms/src/worms/model/Worm.java index d5f470a..c762b52 100644 --- a/OGP1718-Worms/src/worms/model/Worm.java +++ b/OGP1718-Worms/src/worms/model/Worm.java @@ -818,9 +818,37 @@ public class Worm extends GameObject { // 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) { + + } + } //=================================================================================== // endregion