Browse Source

small typo fix in JavaDoc

master^2
jkonert 3 years ago
parent
commit
d1bd4d1460
  1. 21
      GameProject/src/controller/MineController.java

21
GameProject/src/controller/MineController.java

@ -4,7 +4,14 @@ import gameobjects.GameObject;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
/**
* Stops GameObject movement at bottom of level and let it 'fly' in x-direction towards ego object.
* If the object flies outside of the level (by x-coordinate) it is removed.
*
* The behavior looks like a sinking sea mine, which stays at a certain depth and moves left/right to catch the player.
*
*
*/
public class MineController extends ObjectController { public class MineController extends ObjectController {
int rad = 3; int rad = 3;
@ -17,13 +24,19 @@ public class MineController extends ObjectController {
this.lineSpeed = lineSpeed; this.lineSpeed = lineSpeed;
} }
/**
* Fetches ego object by name 'ego' from current level and determines it's x-position.
* The controlled GameObject will move towards this position (in x-direction only).
* y-direction speed is reduced to zero, if the objects reached lower bound of level (high y-values).
* Only deletes the object if it flies out of visible game area.
*/
@Override @Override
public void updateObject() { public void updateObject() {
if (gameObject.getY() >= this.getPlayground().getSizeY() - 10) { if (gameObject.getY() >= this.getPlayground().getSizeY() - 10) {
this.gameObject.setVY(0); this.gameObject.setVY(0);
if (xSpeed == 0.) { if (xSpeed == 0.) {
GameObject ego = getPlayground().getObject("ego");
GameObject ego = this.getPlayground().getObject("ego");
double egoXPos = ego.getX(); double egoXPos = ego.getX();
if (egoXPos > this.gameObject.getX()) { if (egoXPos > this.gameObject.getX()) {
xSpeed = 50; xSpeed = 50;
@ -38,9 +51,9 @@ public class MineController extends ObjectController {
} }
if (this.gameObject.getX() < 0 || (this.gameObject.getX() > this.getPlayground().getSizeX())) { if (this.gameObject.getX() < 0 || (this.gameObject.getX() > this.getPlayground().getSizeX())) {
logger.debug("deleting" + this.gameObject.getId()); logger.debug("deleting" + this.gameObject.getId());
getPlayground().deleteObject(this.gameObject.getId());
this.getPlayground().deleteObject(this.gameObject.getId());
} }
applySpeedVector();
this.applySpeedVector();
} }
} }
Loading…
Cancel
Save