vooga.examples.networking.tictactoe.states
Class TheirTurnState

java.lang.Object
  extended by vooga.engine.state.GameState
      extended by vooga.examples.networking.tictactoe.states.TheirTurnState

public class TheirTurnState
extends GameState

GameState for when the player is waiting for the other player to play.


Field Summary
 
Fields inherited from class vooga.engine.state.GameState
myRenderField, myUpdateField
 
Constructor Summary
TheirTurnState(Game game, ClientConnection connection, PlayField field, PlayState playState)
          Constructor for the GameState shown when it's the other player's turn.
 
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
 

Constructor Detail

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 GameStates
connection - ClientConnection to get the latest message from the socket
field - PlayField for TheirTurnState to render
playState - PlayState to switch to and pass the message whenever it gets a non "theirTurn" String from the socket
Method Detail

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