Merge branch 'master' of gitlab.principis.be:OGP/worms
This commit is contained in:
@@ -814,10 +814,13 @@ public class Worm extends GameObject {
|
||||
* @post the current hit points should be substracted with the given value.
|
||||
* |new.getHitPoints() == old.getHitPoints() - value
|
||||
*/
|
||||
public void incrementHitPoints(long value) {
|
||||
public void decreaseHitPoints(long value) {
|
||||
setHitPoints(getHitPoints() - value);
|
||||
}
|
||||
|
||||
public void incrementHitPoints(long value) {
|
||||
setHitPoints(getHitPoints() + value);
|
||||
}
|
||||
|
||||
//===================================================================================
|
||||
// endregion
|
||||
@@ -830,13 +833,13 @@ public class Worm extends GameObject {
|
||||
Coordinate oldLocation = getLocation();
|
||||
double endY = getLocation().getY();
|
||||
if (! getWorld().isAdjacent(center, minRadius)) {
|
||||
for (double y = oldLocation.getY(); y < 0; y--) {
|
||||
if (y < 0) {
|
||||
for (double y = oldLocation.getY(); y <= (getWorld().getHeight() + 1); y--) {
|
||||
if (y >= (getWorld().getHeight() + 1)) {
|
||||
terminate();
|
||||
}
|
||||
if (getWorld().isAdjacent(center, minRadius)) {
|
||||
double[] newLoc = {oldLocation.getX(), y};
|
||||
setLocation(newLoc);
|
||||
if (getWorld().isAdjacent(center, minRadius)) {
|
||||
endY = y;
|
||||
break;
|
||||
}
|
||||
@@ -844,16 +847,15 @@ public class Worm extends GameObject {
|
||||
}
|
||||
}
|
||||
|
||||
//TODO hitpoints en eventuele botsing
|
||||
double distanceY = getWorld().getHeight();
|
||||
|
||||
long cost = 3 * (long) (oldLocation.getY() - endY);
|
||||
incrementHitPoints(cost);
|
||||
long cost = 3 * (long) Math.floor(oldLocation.getY() - endY);
|
||||
decreaseHitPoints(cost);
|
||||
}
|
||||
|
||||
public void collisionFall(Worm fallingWorm, Worm... worm) {
|
||||
for (Worm stationaryWorm: worm) {
|
||||
|
||||
long value = stationaryWorm.getHitPoints()/2;
|
||||
fallingWorm.incrementHitPoints(value);
|
||||
stationaryWorm.decreaseHitPoints(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user