Browse Source

another JavaDoc fix

master^2
jkonert 3 years ago
parent
commit
95060106fc
  1. 14
      GameProject/src/controller/CollisionAwareEgoController.java
  2. 34
      GameProject/src/controller/EgoController.java

14
GameProject/src/controller/CollisionAwareEgoController.java

@ -37,6 +37,9 @@ public class CollisionAwareEgoController extends EgoController {
this.shot = soundOnShot; this.shot = soundOnShot;
} }
/**
* Copies current values of x,y position and speed vx,vy into attributes. These can be restored by call to {@link #restoreDynamicState()}.
*/
public void saveDynamicState() { public void saveDynamicState() {
this.savex = this.getX(); this.savex = this.getX();
this.savey = this.getY(); this.savey = this.getY();
@ -45,6 +48,10 @@ public class CollisionAwareEgoController extends EgoController {
} }
/**
* Restores formally saved values of x,y position and speed vx,vy from attributes back to the ego object.
* These values should have been stored before by a call to {@link #saveDynamicState()}, otherwise all values will be 0.00.
*/
public void restoreDynamicState() { public void restoreDynamicState() {
this.setX(savex); this.setX(savex);
this.setY(savey); this.setY(savey);
@ -53,6 +60,10 @@ public class CollisionAwareEgoController extends EgoController {
} }
/**
* extends parent class implementation by a check whether or not the ego object collides with any other "obstacle" object.
* If yes, the position stays fixed (by using {@link #saveDynamicState()} and {@link #restoreDynamicState()}.
*/
public boolean stopObject() { public boolean stopObject() {
boolean s = super.stopObject(); boolean s = super.stopObject();
@ -73,6 +84,9 @@ public class CollisionAwareEgoController extends EgoController {
return s; return s;
} }
/**
* calls superclass {@link EgoController#onSpace(KeyEvent, GameObject)} only, if the time elapsed since last pressing of space is above 0.1 ms.
*/
public void onSpace(KeyEvent e, GameObject ego) { public void onSpace(KeyEvent e, GameObject ego) {
double cgt = ego.getGameTime(); double cgt = ego.getGameTime();
if ((cgt - this.lastSpaceAt) > 0.1) { if ((cgt - this.lastSpaceAt) > 0.1) {

34
GameProject/src/controller/EgoController.java

@ -42,21 +42,41 @@ public class EgoController extends ObjectController {
} }
/**
* moves ego up by {@link SpaceInvadersLevel#EGOSPEED}.
* @param kc KeyEvent to process
* @param ego the ego object
*/
public void onUp(KeyEvent kc, GameObject ego) { public void onUp(KeyEvent kc, GameObject ego) {
ego.setVX(0.0); ego.setVX(0.0);
ego.setVY(-SpaceInvadersLevel.EGOSPEED); ego.setVY(-SpaceInvadersLevel.EGOSPEED);
} }
/**
* moves ego down by {@link SpaceInvadersLevel#EGOSPEED}.
* @param kc KeyEvent to process
* @param ego the ego object
*/
public void onDown(KeyEvent kc, GameObject ego) { public void onDown(KeyEvent kc, GameObject ego) {
ego.setVX(0.0); ego.setVX(0.0);
ego.setVY(SpaceInvadersLevel.EGOSPEED); ego.setVY(SpaceInvadersLevel.EGOSPEED);
} }
/**
* moves ego left by {@link SpaceInvadersLevel#EGOSPEED}.
* @param kc KeyEvent to process
* @param ego the ego object
*/
public void onLeft(KeyEvent kc, GameObject ego) { public void onLeft(KeyEvent kc, GameObject ego) {
ego.setVY(0.0); ego.setVY(0.0);
ego.setVX(-SpaceInvadersLevel.EGOSPEED); ego.setVX(-SpaceInvadersLevel.EGOSPEED);
} }
/**
* moves ego right by {@link SpaceInvadersLevel#EGOSPEED}.
* @param kc KeyEvent to process
* @param ego the ego object
*/
public void onRight(KeyEvent kc, GameObject ego) { public void onRight(KeyEvent kc, GameObject ego) {
ego.setVY(0.0); ego.setVY(0.0);
ego.setVX(SpaceInvadersLevel.EGOSPEED); ego.setVX(SpaceInvadersLevel.EGOSPEED);
@ -72,7 +92,7 @@ public class EgoController extends ObjectController {
/** checks the position and respects level boundaries and own radius or width/height set on constructor. /** checks the position and respects level boundaries and own radius or width/height set on constructor.
* *
* @return true if the object reached the boundaries of the level, false otherwise
* @return true if the object reached the boundaries of the level, false otherwise.
*/ */
public boolean stopObject() { public boolean stopObject() {
// check whether ego object is at level boundaries // check whether ego object is at level boundaries
@ -93,7 +113,7 @@ public class EgoController extends ObjectController {
} }
/** behavior for shooting on key space
/** behavior for shooting on key space. Creates a new shot using {#link SimpleShotController} with a {@link RectObject}.
* *
* @param e KeyEvent of the space key * @param e KeyEvent of the space key
* @param ego EgoObject instance (used to determine position of shot object's start) * @param ego EgoObject instance (used to determine position of shot object's start)
@ -119,7 +139,7 @@ public class EgoController extends ObjectController {
/** /**
* updates position based on key events (mouse currently ignored)
* updates position based on key events (mouse currently ignored).
*/ */
public void updateObject() { public void updateObject() {
@ -141,9 +161,9 @@ public class EgoController extends ObjectController {
} }
/** /**
* Generelle Idee: Wenn eine Taste gedrückt wird wird sie gespeichert. wenn die zuvor
* Generelle Idee: Wenn eine Taste gedrückt wird wird sie gespeichert. wenn die zuvor
* gespeicherte Taste wieder losgelassen wird stoppt das Ego-Objekt. Falls vor dem Loslassen * gespeicherte Taste wieder losgelassen wird stoppt das Ego-Objekt. Falls vor dem Loslassen
* eine andere Taste gedrückt wird, wird diese gespeichert und die alte vergessen. Dh das
* eine andere Taste gedrückt wird, wird diese gespeichert und die alte vergessen. Dh das
* loslassen der alten Taste stoppt das Objekt nicht. Spezialfall: space, das loslassen von * loslassen der alten Taste stoppt das Objekt nicht. Spezialfall: space, das loslassen von
* space stoppt das Objekt nicht! * space stoppt das Objekt nicht!
*/ */
@ -154,8 +174,8 @@ public class EgoController extends ObjectController {
} }
/** /**
* Nur eine losgelassene Taste die auch vorher gedrückt wurde stoppt das Objekt. Eine
* losgelassene Taste die nicht vorher gedrückt wurde bzw vergessen wurde stoppt das Objekt
* Nur eine losgelassene Taste die auch vorher gedrückt wurde stoppt das Objekt. Eine
* losgelassene Taste die nicht vorher gedrückt wurde bzw vergessen wurde stoppt das Objekt
* nicht * nicht
*/ */
if (released == true) { if (released == true) {

Loading…
Cancel
Save