3D Game Programming All in One By Kenneth C. Finney
Chapter 4 Game Programming
Game Programming Torque Script –Strings Tagged and standard types Formatting codes –Objects Methods and properties –Namespaces Local, global, object, & arbitrary –Datablocks Static data sent from server to clients
Game Programming Game Structure –root main module in game root folder –Common code folder Code that will not change much between project –Control code folder Define the game Control game play Manage game resources
Game Programming scripts common control data game root
Game Programming Server vs. Client design issues –Server-side: authentication game play decisions & scoring resources –Client-side: interfaces setup navigation
Game Programming common Functionality –Authentication –Messaging –In-game editors –Debugger –Lighting –Help –User interfaces
Game Programming Lab 1: "emaga4" –Build a bare bones simulation –Launch a server –Connect client locally (part of same system process) –Load a mission –Spawn player avatar –Provide minimal player movement
Game Programming root main module –Generic initialization –Command line parsing –Help package –Invokes packages and add-ons
Game Programming control main –Load control packages & modules –Control initialization
Game Programming control/initialize –Initialize server –Initialize client
Game Programming control/client –Create key bindings –Define 3D view callback –Define 3D view interface –Create avatar motion hooks –Stub routines to handle unused calls from common code
Game Programming control/server –Contains code to run when server starts –Handles client connection to server –Creates client's player avatars –A couple of stub routines
Game Programming control/player –Contains definition of player datablock –Defines player creation/destruction methods
Summary Strings are enclosed in double-quotes ("), tagged strings are in single-quotes(') Tagged strings reduce network loads, transmit once, then use a reference number Torque Script supports objects with properties and methods, using the dot operator Namespaces help manage variable names and usage Datablocks are used to carry data for game objects from the server to clients
Summary Organize your game scripts in ways that make sense to you and your team Splitting the control scripts and the common code is a good idea, build on that For multiplayer games, put cheat-sensitive code on the server, all else on the client