Package controller
Class ObjectController
java.lang.Object
controller.ObjectController
- Direct Known Subclasses:
EgoController
,EnemyController
,FallingStarController
,LimitedTimeController
,MineController
,SimpleShotController
Class that controls the LOGICAL behavior of an object independently of how it is displayed or
drawn. The most important method here is
updateObject()
: this method is, by various
indirections, called exactly once per game time step for every object that is on the playground.
It has, by virtue of the member variables gameObject
full access to
- the object it is controlling
- the playground this object belongs to
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Convenience method: simply moves the object forward one step from its present position, using its present speed.double
double
getVX()
double
getVY()
double
getX()
double
getY()
void
void
setObject
(GameObject gameObject) void
setPlayground
(Playground playground) void
setVX
(double vx) void
setVY
(double vy) void
setX
(double x) void
setY
(double y) abstract void
Is called once every game time step by the game itself.
-
Constructor Details
-
ObjectController
public ObjectController()
-
-
Method Details
-
setObject
-
setDummy
-
updateObject
public abstract void updateObject()Is called once every game time step by the game itself. NEVER call this directly, not necessary!
The method can do whatever it likes, including nothing. The attributegameObject
contains a reference to the controlled object, which allows access to the Playground the object belongs to (useful for getting the pixel size in x and y of the playing field.
Recommended: when implementing this method, call at the endapplySpeedVector()
method. This is a helper method that sets the new x,y coordinates for thegameObject
correctly. -
applySpeedVector
public void applySpeedVector()Convenience method: simply moves the object forward one step from its present position, using its present speed. -
getTimestep
public double getTimestep() -
getX
public double getX() -
getY
public double getY() -
getVX
public double getVX() -
getVY
public double getVY() -
setX
public void setX(double x) -
setY
public void setY(double y) -
setVX
public void setVX(double vx) -
setVY
public void setVY(double vy) -
getPlayground
-
setPlayground
-