Class GameEngine
java.lang.Object
org.comp2059.pong.controller.GameEngine
Owns one game's state and advances it independently of the UI timer.
-
Constructor Summary
ConstructorsConstructorDescriptionGameEngine(PaddleController leftController, PaddleController rightController, int ballRadius, int serveDelayMillis) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddScoreListener(ScoreListener listener) getBall()intintbooleanbooleanvoidremoveScoreListener(ScoreListener listener) voidreset(int width, int height) Resets the game to the current play area, ready for Start.voidstart()voidupdate(long nowNanos) Advances one 10ms game tick; nowNanos must come from a monotonic clock.
-
Constructor Details
-
GameEngine
public GameEngine(PaddleController leftController, PaddleController rightController, int ballRadius, int serveDelayMillis)
-
-
Method Details
-
addScoreListener
-
removeScoreListener
-
reset
public void reset(int width, int height) Resets the game to the current play area, ready for Start. -
start
public void start() -
update
public void update(long nowNanos) Advances one 10ms game tick; nowNanos must come from a monotonic clock. -
getBall
-
getLeftPaddle
-
getRightPaddle
-
getScoreLeft
public int getScoreLeft() -
getScoreRight
public int getScoreRight() -
isInitialized
public boolean isInitialized() -
isRunning
public boolean isRunning()
-