Main Page Modules Namespaces C++ Classes Compound List File List Index
TNL: Zap Namespace Reference

# Zap Namespace Reference

## Detailed Description

Zap - a 2D space game demonstrating the full capabilities of the Torque Network Library.

The Zap example game is a 2D vector-graphics game that utilizes some of the more advanced features of the TNL. Zap also demonstrates the use of client-side prediction, and interpolation to present a consistent simulation to clients over a connection with perceptible latency.

Zap can run in 3 modes - as a client, a client and server, or a dedicated server. The dedicated server option is available only as a launch parameter from the command line.

If it is run as a client, Zap uses the GLUT library to perform cross-platform window intialization, event processing and OpenGL setup.

Zap implements a simple game framework. The GameObject class is the root class for all of the various objects in the Zap world, including Ship, Barrier and Projectile instances. The Game class, which is instanced once for the client and once for the server, manages the current list of GameObject instances.

Zap clients can connect to servers directly that are on the same LAN or for which the IP address is known. Zap is also capable of talking to the TNL master server and using its arranged connection functionality to talk to servers.

The simplified user interface for Zap is managed entirely through subclasses of the UserInterface class. Each UserInterface subclass represents one "screen" in the UI. The GameUserInterface is the most complicated, being responsible for the user interface while the client is actually playing a game. The only other somewhat complicated UI is the QueryServersUserInterface class, which implements a full server browser for choosing from a list of LAN and master server queried servers.

## Data Structures

class | Barrier
| The Barrier class represents rectangular barriers that player controlled Ship instances cannot pass through. More...
class | ControlObjectConnection
class | CTFGameType
class | EngineeredObject
class | ForceField
class | ForceFieldProjector
class | Turret
class | FlagItem
class | Game
| Base class for server and client Game subclasses. More...
class | ServerGame
class | ClientGame
class | GameConnection
class | LevelLoader
class | GameNetInterface
struct | DamageInfo
class | GameObject
class | ClientRef
class | GameType
struct | ShipWeaponInfo
struct | ProjectileInfo
class | GoalZone
class | GridDatabase
class | HuntersGameType
class | HuntersFlagItem
class | HuntersNexusObject
class | Item
class | PickupItem
class | LoadoutHelper
class | MasterServerConnection
struct | Move
class | MoveObject
struct | Point
struct | Color
struct | Rect
class | Projectile
class | GrenadeProjectile
class | Mine
class | VChatHelper
class | RabbitGameType
struct | SFXProfile
class | SFXObject
class | Ship
class | SoccerGameType
class | SoccerBallItem
class | FXTrail
class | Teleporter
class | Timer
class | UserInterface
class | CreditsFX
class | CreditsScroller
class | CreditsUserInterface
class | EditorUserInterface
class | EditorMenuUserInterface
class | GameUserInterface
class | InstructionsUserInterface
struct | MenuItem
class | MenuUserInterface
class | MainMenuUserInterface
class | OptionsMenuUserInterface
class | GameMenuUserInterface
class | LevelMenuUserInterface
class | AdminMenuUserInterface
class | PlayerMenuUserInterface
class | TextEntryUserInterface
class | NameEntryUserInterface
class | PasswordEntryUserInterface
class | AdminPasswordEntryUserInterface
class | QueryServersUserInterface
class | VoiceEncoder
| The VoiceEncoder class is an abstract base class for the various voice compression algorithms supported by Zap - initially just the HawkVoice variable bitrate LPC10 codec. More...
class | VoiceDecoder
| The VoiceDecoder class is an abstract base class for the various voice decompression algorithms supported by Zap - initially just the HawkVoice variable bitrate LPC10 codec. More...
class | LPC10VoiceEncoder
| The LPC10VoiceEncoder class implements the HawkVoice LPC10 codec compressor. More...
class | LPC10VoiceDecoder
| The LPC10VoiceDecoder class implements the HawkVoice LPC10 codec decompressor. More...
class | GSMVoiceEncoder
| The GSMVoiceEncoder class implements the HawkVoice GSM codec compressor. More...
class | GSMVoiceDecoder
| The GSMVoiceDecoder class implements the HawkVoice GSM codec decompressor. More...

## Namespaces

namespace | FXManager

## Typedefs

typedef RefPtr< SFXObject > | SFXHandle

## Enumerations

enum | GameObjectType { UnknownType = BIT(0), ShipType = BIT(1), BarrierType = BIT(2), MoveableType = BIT(3),
ProjectileType = BIT(4),
ItemType = BIT(5),
ResourceItemType = BIT(6),
EngineeredType = BIT(7),
ForceFieldType = BIT(8),
LoadoutZoneType = BIT(9),
MineType = BIT(10),
TestItemType = BIT(11),
FlagType = BIT(12),
TurretTargetType = BIT(13),
DeletedType = BIT(30),
CommandMapVisType = BIT(31),
DamagableTypes = ShipType | MoveableType | ProjectileType | ItemType | ResourceItemType | EngineeredType | MineType,
MotionTriggerTypes = ShipType | ResourceItemType | TestItemType,
AllObjectTypes = 0xFFFFFFFF
}
enum | WeaponTypes { WeaponPhaser = 0, WeaponBounce, WeaponTriple, WeaponBurst,
WeaponMineLayer,
WeaponTurretBlaster,
WeaponCount
}
enum | WeaponConsts { MaxFireDelay = 2048 }
enum | { NumSparkColors = 4 }
enum | ProjectileType { ProjectilePhaser, ProjectileBounce, ProjectileTriple, ProjectileTurret,
ProjectileTypeCount
}
enum | ControllerTypeType { LogitechWingman, LogitechDualAction, SaitekDualAnalog, PS2DualShock,
XBoxController,
XBoxControllerOnXBox,
ControllerTypeCount
}
enum | ButtonInfo { MaxJoystickAxes = 12, MaxJoystickButtons = 14, ControllerButton1 = 1 << 0, ControllerButton2 = 1 << 1,
ControllerButton3 = 1 << 2,
ControllerButton4 = 1 << 3,
ControllerButton5 = 1 << 4,
ControllerButton6 = 1 << 5,
ControllerButtonLeftTrigger = 1 << 6,
ControllerButtonRightTrigger = 1 << 7,
ControllerGameButtonCount = 8,
ControllerButtonStart = 1 << 8,
ControllerButtonBack = 1 << 9,
ControllerButtonDPadUp = 1 << 10,
ControllerButtonDPadDown = 1 << 11,
ControllerButtonDPadLeft = 1 << 12,
ControllerButtonDPadRight = 1 << 13
}
enum | SFXProfiles { SFXVoice, SFXNone, SFXPhaserProjectile, SFXPhaserImpact,
SFXBounceProjectile,
SFXBounceImpact,
SFXTripleProjectile,
SFXTripleImpact,
SFXTurretProjectile,
SFXTurretImpact,
SFXGrenadeProjectile,
SFXMineDeploy,
SFXMineArm,
SFXMineExplode,
SFXShipExplode,
SFXShipHeal,
SFXShipBoost,
SFXBounceWall,
SFXBounceObject,
SFXBounceShield,
SFXShieldActive,
SFXSensorActive,
SFXRepairActive,
SFXCloakActive,
SFXFlagCapture,
SFXFlagDrop,
SFXFlagReturn,
SFXFlagSnatch,
SFXTeleportIn,
SFXTeleportOut,
SFXForceFieldUp,
SFXForceFieldDown,
SFXUIBoop,
SFXUICommUp,
SFXUICommDown,
SFXIncomingMessage,
NumSFXBuffers
}
enum | ShipModule { ModuleShield, ModuleBoost, ModuleSensor, ModuleRepair,
ModuleEngineer,
ModuleCloak,
ModuleCount
}
enum | EngineerBuildObjects { EngineeredTurret, EngineeredForceField }

## Functions

void | engClientCreateObject (GameConnection *connection, U32 object)
void | renderFlag (Point pos, Color c)
void | hostGame (bool dedicated, Address bindAddress)
void | joinGame (Address remoteAddress, bool isFromMaster, bool local=false)
void | endGame ()
void | glVertex (Point p)
void | glColor (Color c, float alpha=1)
void | drawCircle (Point pos, F32 radius)
void | fillCircle (Point pos, F32 radius)
void | renderCenteredString (Point pos, U32 size, const char *string)
void | renderShip (Color c, F32 alpha, F32 thrusts[], F32 health, F32 radius, bool cloakActive, bool shieldActive)
void | renderTeleporter (Point pos, U32 type, bool in, S32 time, F32 radiusFraction, F32 radius, F32 alpha)
void | renderTurret (Color c, Point anchor, Point normal, bool enabled, F32 health, F32 barrelAngle, F32 aimOffset)
void | renderLoadoutZone (Color c, Vector< Point > &bounds, Rect extent)
void | renderProjectile (Point pos, U32 type, U32 time)
void | renderMine (Point pos, bool armed, bool visible)
void | renderGrenade (Point pos)
void | renderRepairItem (Point pos)
void | renderForceFieldProjector (Point pos, Point normal, Color teamColor, bool enabled)
void | renderForceField (Point start, Point end, Color c, bool fieldUp)
void | renderGoalZone (Vector< Point > &bounds, Color c, bool isFlashing)
void | createWeaponProjectiles (U32 weapon, Point &dir, Point &shooterPos, Point &shooterVel, F32 shooterRadius, GameObject *shooter)
void | getModifierState (bool &shiftDown, bool &controlDown, bool &altDown)
void | InitJoystick ()
const char * | GetJoystickName ()
S32 | autodetectJoystickType ()
void | ShutdownJoystick ()
bool | ReadJoystick (F32 axes[MaxJoystickAxes], U32 &buttonMask, U32 &hatMask)
F32 | radiansToDegrees (F32 angle)
F32 | radiansToUnit (F32 angle)
F32 | unitToRadians (F32 angle)
void | SFXInit ()
void | SFXShutdown ()
void | SFXProcess ()
void | SFXSetListenerParams (Point position, Point velocity)
bool | PolygonSweptCircleIntersect (const Point *inVertices, int inNumVertices, const Point &inBegin, const Point &inDelta, Point::member_type inRadius, Point &outPoint, Point::member_type &outFraction)

## Variables

ServerGame * | gServerGame
ClientGame * | gClientGame
Address | gMasterAddress
static char * | gConnectStatesTable []
ShipWeaponInfo | gWeapons [WeaponCount]
ProjectileInfo | gProjInfo [ProjectileTypeCount]
const F32 | radiansToDegreesConversion = 360.0f * FloatInverse2Pi
static const float | DefaultLineWidth = 2.0f
CreditsUserInterface | gCreditsUserInterface
EditorUserInterface | gEditorUserInterface
EditorMenuUserInterface | gEditorMenuUserInterface
GameUserInterface | gGameUserInterface
InstructionsUserInterface | gInstructionsUserInterface
MainMenuUserInterface | gMainMenuUserInterface
OptionsMenuUserInterface | gOptionsMenuUserInterface
GameMenuUserInterface | gGameMenuUserInterface
LevelMenuUserInterface | gLevelMenuUserInterface
AdminMenuUserInterface | gAdminMenuUserInterface
PlayerMenuUserInterface | gPlayerMenuUserInterface
NameEntryUserInterface | gNameEntryUserInterface
PasswordEntryUserInterface | gPasswordEntryUserInterface
AdminPasswordEntryUserInterface | gAdminPasswordEntryUserInterface
QueryServersUserInterface | gQueryServersUserInterface

## Typedef Documentation

typedef RefPtr<SFXObject> Zap::SFXHandle

## Enumeration Type Documentation

enum Zap::GameObjectType

Enumerator:

  UnknownType |
  ShipType |
  BarrierType |
  MoveableType |
  ProjectileType |
  ItemType |
  ResourceItemType |
  EngineeredType |
  ForceFieldType |
  LoadoutZoneType |
  MineType |
  TestItemType |
  FlagType |
  TurretTargetType |
  DeletedType |
  CommandMapVisType |
  DamagableTypes |
  MotionTriggerTypes |
  AllObjectTypes |

enum Zap::WeaponTypes

Enumerator:

  WeaponPhaser |
  WeaponBounce |
  WeaponTriple |
  WeaponBurst |
  WeaponMineLayer |
  WeaponTurretBlaster |
  WeaponCount |

enum Zap::WeaponConsts

Enumerator:

  MaxFireDelay |

anonymous enum

Enumerator:

  NumSparkColors |

enum Zap::ProjectileType

Enumerator:

  ProjectilePhaser |
  ProjectileBounce |
  ProjectileTriple |
  ProjectileTurret |
  ProjectileTypeCount |

enum Zap::ControllerTypeType

Enumerator:

  LogitechWingman |
  LogitechDualAction |
  SaitekDualAnalog |
  PS2DualShock |
  XBoxController |
  XBoxControllerOnXBox |
  ControllerTypeCount |

enum Zap::ButtonInfo

Enumerator:

  MaxJoystickAxes |
  MaxJoystickButtons |
  ControllerButton1 |
  ControllerButton2 |
  ControllerButton3 |
  ControllerButton4 |
  ControllerButton5 |
  ControllerButton6 |
  ControllerButtonLeftTrigger |
  ControllerButtonRightTrigger |
  ControllerGameButtonCount |
  ControllerButtonStart |
  ControllerButtonBack |
  ControllerButtonDPadUp |
  ControllerButtonDPadDown |
  ControllerButtonDPadLeft |
  ControllerButtonDPadRight |

enum Zap::SFXProfiles

Enumerator:

  SFXVoice |
  SFXNone |
  SFXPhaserProjectile |
  SFXPhaserImpact |
  SFXBounceProjectile |
  SFXBounceImpact |
  SFXTripleProjectile |
  SFXTripleImpact |
  SFXTurretProjectile |
  SFXTurretImpact |
  SFXGrenadeProjectile |
  SFXMineDeploy |
  SFXMineArm |
  SFXMineExplode |
  SFXShipExplode |
  SFXShipHeal |
  SFXShipBoost |
  SFXBounceWall |
  SFXBounceObject |
  SFXBounceShield |
  SFXShieldActive |
  SFXSensorActive |
  SFXRepairActive |
  SFXCloakActive |
  SFXFlagCapture |
  SFXFlagDrop |
  SFXFlagReturn |
  SFXFlagSnatch |
  SFXTeleportIn |
  SFXTeleportOut |
  SFXForceFieldUp |
  SFXForceFieldDown |
  SFXUIBoop |
  SFXUICommUp |
  SFXUICommDown |
  SFXIncomingMessage |
  NumSFXBuffers |

enum Zap::ShipModule

Enumerator:

  ModuleShield |
  ModuleBoost |
  ModuleSensor |
  ModuleRepair |
  ModuleEngineer |
  ModuleCloak |
  ModuleCount |

enum Zap::EngineerBuildObjects

Enumerator:

  EngineeredTurret |
  EngineeredForceField |

## Function Documentation

void Zap::engClientCreateObject | ( | GameConnection * | connection,
|  | U32 | object |
| ) |  |  |

void Zap::renderFlag | ( | Point | pos,
|  | Color | c |
| ) |  |  |

void Zap::hostGame | ( | bool | dedicated,
|  | Address | bindAddress |
| ) |  |  |

void Zap::joinGame | ( | Address | remoteAddress,
|  | bool | isFromMaster,
|  | bool | local = `false` |
| ) |  |  |

void Zap::endGame | ( |  | ) |

void Zap::glVertex | ( | Point | p | ) |

void Zap::glColor | ( | Color | c,
|  | float | alpha = `1` |
| ) |  |  |

void Zap::drawCircle | ( | Point | pos,
|  | F32 | radius |
| ) |  |  |

void Zap::fillCircle | ( | Point | pos,
|  | F32 | radius |
| ) |  |  |

void Zap::renderCenteredString | ( | Point | pos,
|  | U32 | size,
|  | const char * | string |
| ) |  |  |

void Zap::renderShip | ( | Color | c,
|  | F32 | alpha,
|  | F32 | thrusts[],
|  | F32 | health,
|  | F32 | radius,
|  | bool | cloakActive,
|  | bool | shieldActive |
| ) |  |  |

void Zap::renderTeleporter | ( | Point | pos,
|  | U32 | type,
|  | bool | in,
|  | S32 | time,
|  | F32 | radiusFraction,
|  | F32 | radius,
|  | F32 | alpha |
| ) |  |  |

void Zap::renderTurret | ( | Color | c,
|  | Point | anchor,
|  | Point | normal,
|  | bool | enabled,
|  | F32 | health,
|  | F32 | barrelAngle,
|  | F32 | aimOffset |
| ) |  |  |

void Zap::renderLoadoutZone | ( | Color | c,
|  | Vector< Point > & | bounds,
|  | Rect | extent |
| ) |  |  |

void Zap::renderProjectile | ( | Point | pos,
|  | U32 | type,
|  | U32 | time |
| ) |  |  |

void Zap::renderMine | ( | Point | pos,
|  | bool | armed,
|  | bool | visible |
| ) |  |  |

void Zap::renderGrenade | ( | Point | pos | ) |

void Zap::renderRepairItem | ( | Point | pos | ) |

void Zap::renderForceFieldProjector | ( | Point | pos,
|  | Point | normal,
|  | Color | teamColor,
|  | bool | enabled |
| ) |  |  |

void Zap::renderForceField | ( | Point | start,
|  | Point | end,
|  | Color | c,
|  | bool | fieldUp |
| ) |  |  |

void Zap::renderGoalZone | ( | Vector< Point > & | bounds,
|  | Color | c,
|  | bool | isFlashing |
| ) |  |  |

void Zap::createWeaponProjectiles | ( | U32 | weapon,
|  | Point & | dir,
|  | Point & | shooterPos,
|  | Point & | shooterVel,
|  | F32 | shooterRadius,
|  | GameObject * | shooter |
| ) |  |  |

void Zap::getModifierState | ( | bool & | shiftDown,
|  | bool & | controlDown,
|  | bool & | altDown |
| ) |  |  |

void Zap::InitJoystick | ( |  | ) |

const char* Zap::GetJoystickName | ( |  | ) |

S32 Zap::autodetectJoystickType | ( |  | ) |

void Zap::ShutdownJoystick | ( |  | ) |

bool Zap::ReadJoystick | ( | F32 | axes[MaxJoystickAxes],
|  | U32 & | buttonMask,
|  | U32 & | hatMask |
| ) |  |  |

F32 Zap::radiansToDegrees | ( | F32 | angle | ) | `[inline]`

F32 Zap::radiansToUnit | ( | F32 | angle | ) | `[inline]`

F32 Zap::unitToRadians | ( | F32 | angle | ) | `[inline]`

void Zap::SFXInit | ( |  | ) |

void Zap::SFXShutdown | ( |  | ) |

void Zap::SFXProcess | ( |  | ) |

void Zap::SFXSetListenerParams | ( | Point | position,
|  | Point | velocity |
| ) |  |  |

bool Zap::PolygonSweptCircleIntersect | ( | const Point * | inVertices,
|  | int | inNumVertices,
|  | const Point & | inBegin,
|  | const Point & | inDelta,
|  | Point::member_type | inRadius,
|  | Point & | outPoint,
|  | Point::member_type & | outFraction |
| ) |  |  |

## Variable Documentation

ServerGame* Zap::gServerGame

ClientGame* Zap::gClientGame

Address Zap::gMasterAddress

char* Zap::gConnectStatesTable[]`[static]`

Initial value:

     {
          "Not connected...",
          "Sending challenge request.",
          "Punching through firewalls.",
          "Computing puzzle solution.",
          "Sent connect request.",
          "Connection timed out.",
          "Connection rejected.",
          "Connected.",
          "Disconnected.",
          "Connection timed out.",
          ""
    }

ShipWeaponInfo Zap::gWeapons[WeaponCount]

ProjectileInfo Zap::gProjInfo[ProjectileTypeCount]

const F32 Zap::radiansToDegreesConversion = 360.0f * FloatInverse2Pi

const float Zap::DefaultLineWidth = 2.0f`[static]`

CreditsUserInterface Zap::gCreditsUserInterface

EditorUserInterface Zap::gEditorUserInterface

EditorMenuUserInterface Zap::gEditorMenuUserInterface

GameUserInterface Zap::gGameUserInterface

InstructionsUserInterface Zap::gInstructionsUserInterface

MainMenuUserInterface Zap::gMainMenuUserInterface

OptionsMenuUserInterface Zap::gOptionsMenuUserInterface

GameMenuUserInterface Zap::gGameMenuUserInterface

LevelMenuUserInterface Zap::gLevelMenuUserInterface

AdminMenuUserInterface Zap::gAdminMenuUserInterface

PlayerMenuUserInterface Zap::gPlayerMenuUserInterface

NameEntryUserInterface Zap::gNameEntryUserInterface

PasswordEntryUserInterface Zap::gPasswordEntryUserInterface

AdminPasswordEntryUserInterface Zap::gAdminPasswordEntryUserInterface

QueryServersUserInterface Zap::gQueryServersUserInterface