vooga.examples.networking.tictactoe.states
Class TheirTurnState
java.lang.Object
vooga.engine.state.GameState
vooga.examples.networking.tictactoe.states.TheirTurnState
public class TheirTurnState
- extends GameState
GameState for when the player is waiting for the other player to play.
Method Summary |
void |
initialize()
The initialize method sets up specific variables and parameters necessary
to the specific functioning of the GameState. |
void |
render(java.awt.Graphics2D g)
Renders all sprites stored in the GameState's renderGroups. |
void |
update(long t)
If it receives a message from the socket that is not "theirTurn", then switch to the PlayState and tell the PlayState what the message was. |
Methods inherited from class vooga.engine.state.GameState |
activate, addGroup, addPlayField, addRenderPlayField, addRenderState, addState, addUpdatePlayField, addUpdateState, deactivate, equals, getGroup, getRenderField, getUpdateField, isActive, removeEverything |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TheirTurnState
public TheirTurnState(Game game,
ClientConnection connection,
PlayField field,
PlayState playState)
- Constructor for the GameState shown when it's the other player's turn.
- Parameters:
game
- Game to be able to switch GameStatesconnection
- ClientConnection to get the latest message from the socketfield
- PlayField for TheirTurnState to renderplayState
- PlayState to switch to and pass the message whenever it gets a non "theirTurn" String from the socket
update
public void update(long t)
- If it receives a message from the socket that is not "theirTurn", then switch to the PlayState and tell the PlayState what the message was.
checkDelay is a way around a rendering issue since render is called after update and thus would never be called if I block the main thread
with the connection.getData() call.
- Overrides:
update
in class GameState
render
public void render(java.awt.Graphics2D g)
- Description copied from class:
GameState
- Renders all sprites stored in the GameState's renderGroups.
- Overrides:
render
in class GameState
initialize
public void initialize()
- Description copied from class:
GameState
- The initialize method sets up specific variables and parameters necessary
to the specific functioning of the GameState. This should include all of
the necessary initialization for the GameState's specific use, rather
than anything broadly required for all GameStates.
- Specified by:
initialize
in class GameState