News SF.net Project Frequently Asked Questions Documentation Downloads Mailing Lists How to Contribute

SourceForge.net Logo

Changing the way games are made and played.

TNLTest::TestGame class Reference

TNLTest::TestGame Class Reference

#include <testGame.h>


Detailed Description

The TestGame class manages a TNLTest client or server instance.

TestGame maintains a list of all the Player and Building objects in the playing area, and interfaces with the specific platform's windowing system to respond to user input and render the current game display.


Public Member Functions

 TestGame (bool server, const TNL::Address &bindAddress, const TNL::Address &pingAddress)
 Constructor for TestGame, determines whether this game will be a client or a server, and what addresses to bind to and ping.

 ~TestGame ()
 Destroys a game, freeing all Player and Building objects associated with it.

void createLocalConnection (TestGame *serverGame)
 createLocalConnection demonstrates the use of so-called "short circuit" connections for connecting to a server NetInterface in the same process as this client game.

void tick ()
 Called periodically by the platform windowing code, tick will update all the players in the simulation as well as tick() the game's network interface.

void renderFrame (int width, int height)
 renderFrame is called by the platform windowing code to notify the game that it should render the current world using the specified window area.

void moveMyPlayerTo (Position newPosition)
 moveMyPlayerTo is called by the platform windowing code in response to user input.


Data Fields

TNL::Vector< Player * > players
 vector of player objects in the game

TNL::Vector< Building * > buildings
 vector of buildings in the game

bool isServer
 was this game created to be a server?

TestNetInterfacemyNetInterface
 network interface for this game

TNL::U32 lastTime
 last time that tick() was called

TNL::SafePtr< PlayerserverPlayer
 the player that the server controls

TNL::SafePtr< PlayerclientPlayer
 the player that this client controls, if this game is a client


Constructor & Destructor Documentation

TNLTest::TestGame::TestGame bool  server,
const TNL::Address bindAddress,
const TNL::Address pingAddress
 

Constructor for TestGame, determines whether this game will be a client or a server, and what addresses to bind to and ping.

If this game is a server, it will construct 50 random buildings and 15 random AI players to populate the "world" with. TestGame also constructs an AsymmetricKey to demonstrate establishing secure connections with clients and servers.

TNLTest::TestGame::~TestGame  ) 
 

Destroys a game, freeing all Player and Building objects associated with it.


Member Function Documentation

void TNLTest::TestGame::createLocalConnection TestGame serverGame  ) 
 

createLocalConnection demonstrates the use of so-called "short circuit" connections for connecting to a server NetInterface in the same process as this client game.

void TNLTest::TestGame::tick  ) 
 

Called periodically by the platform windowing code, tick will update all the players in the simulation as well as tick() the game's network interface.

void TNLTest::TestGame::renderFrame int  width,
int  height
 

renderFrame is called by the platform windowing code to notify the game that it should render the current world using the specified window area.

void TNLTest::TestGame::moveMyPlayerTo Position  newPosition  ) 
 

moveMyPlayerTo is called by the platform windowing code in response to user input.


Field Documentation

TNL::Vector<Player *> TNLTest::TestGame::players
 

vector of player objects in the game

TNL::Vector<Building *> TNLTest::TestGame::buildings
 

vector of buildings in the game

bool TNLTest::TestGame::isServer
 

was this game created to be a server?

TestNetInterface* TNLTest::TestGame::myNetInterface
 

network interface for this game

TNL::U32 TNLTest::TestGame::lastTime
 

last time that tick() was called

TNL::SafePtr<Player> TNLTest::TestGame::serverPlayer
 

the player that the server controls

TNL::SafePtr<Player> TNLTest::TestGame::clientPlayer
 

the player that this client controls, if this game is a client