Package controller
Class CollisionAwareEgoController
java.lang.Object
controller.ObjectController
controller.EgoController
controller.CollisionAwareEgoController
An EgoController which cannot move through obstacle objects (is collission aware). Only respects
GameObjects that have the String 'obstacle' in their name.
-
Constructor Summary
ConstructorDescriptionCollisionAwareEgoController
(double egoRad) CollisionAwareEgoController
(double egoRad, File soundOnShot) -
Method Summary
Modifier and TypeMethodDescriptionvoid
onSpace
(KeyEvent e, GameObject ego) calls superclassEgoController.onSpace(KeyEvent, GameObject)
only, if the time elapsed since last pressing of space is above 0.1 ms.void
Restores formally saved values of x,y position and speed vx,vy from attributes back to the ego object.void
Copies current values of x,y position and speed vx,vy into attributes.boolean
extends parent class implementation by a check whether or not the ego object collides with any other "obstacle" object.Methods inherited from class controller.EgoController
onDown, onLeft, onRight, onStop, onUp, updateObject
Methods inherited from class controller.ObjectController
applySpeedVector, getPlayground, getTimestep, getVX, getVY, getX, getY, setDummy, setObject, setPlayground, setVX, setVY, setX, setY
-
Constructor Details
-
CollisionAwareEgoController
public CollisionAwareEgoController(double egoRad) - Parameters:
egoRad
- radius of ego object to be used.
-
CollisionAwareEgoController
- Parameters:
egoRad
- radius of ego object to be used.soundOnShot
- WAV file to be played on shot
-
-
Method Details
-
saveDynamicState
public void saveDynamicState()Copies current values of x,y position and speed vx,vy into attributes. These can be restored by call torestoreDynamicState()
. -
restoreDynamicState
public void restoreDynamicState()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 tosaveDynamicState()
, otherwise all values will be 0.00. -
stopObject
public boolean stopObject()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 usingsaveDynamicState()
andrestoreDynamicState()
.- Overrides:
stopObject
in classEgoController
- Returns:
- true if the object reached the boundaries of the level, false otherwise.
-
onSpace
calls superclassEgoController.onSpace(KeyEvent, GameObject)
only, if the time elapsed since last pressing of space is above 0.1 ms.- Overrides:
onSpace
in classEgoController
- Parameters:
e
- KeyEvent of the space keyego
- EgoObject instance (used to determine position of shot object's start)
-