game.c File Reference

Game specific code. More...

#include "game.h"
#include "gameconfig.h"
#include "color.h"
#include "net.h"
#include "obstacle.h"
#include "tanksprite.h"
#include "playernet.h"
#include "random.h"
#include "notice.h"
#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>

Include dependency graph for game.c:

Go to the source code of this file.

Defines

#define BatchBit(pid)   (1 << ((pid) & 0x1F))
 Computes the bit of a player's flag at the corresponding index of the batch flags.
#define BatchIndex(pid)   ((pid) >> 5)
 Computes the index of a player's flag within the batch flags.
#define QueuePlaceName(pid)   batchNameDraw[BatchIndex(pid)] |= BatchBit(pid)
 Sets the flag that indicates the given player's name label needs to be redrawn.
#define QueuePlaceName   __func_QueuePlaceName
 Sets the flag that indicates the given player's name label needs to be redrawn.
#define QueuePlaceShell(pid)   batchShellDraw[BatchIndex(pid)] |= BatchBit(pid)
 Sets the flag that indicates the given player's shell needs to be redrawn.
#define QueuePlaceShell   __func_QueuePlaceShell
 Sets the flag that indicates the given player's shell needs to be redrawn.
#define QueuePlaceTank(pid)   batchTankDraw[BatchIndex(pid)] |= BatchBit(pid)
 Sets the flag that indicates the given player's tank needs to be redrawn.
#define QueuePlaceTank   __func_QueuePlaceTank
 Sets the flag that indicates the given player's tank needs to be redrawn.

Typedefs

typedef void(*) PlacementFunc (void *data)
 The function prototype used to place tanks, shells, and names whenever they change or move.

Functions

static void BatchRender (Uint32 *batch, PlacementFunc placement, long offset)
 Renders the player's items who's flags are set using the given function.
void DisablePlayerLabels ()
 Disables the display of labels showing player names.
void EnablePlayerLabels ()
 Enables the display of labels showing player names.
static void FixTankCollision (Player *p)
 Attempts to correct a collision between this tank and another tank.
void HandleInput (Uint8 *eventState)
 Responds to the collected user input by changing data for the local player.
void MoveShell (Player *p)
 Moves a player's shell.
void MoveTank (Player *p, int factor)
 Moves a player's tank.
void PlacePlayerLabel (Player *p)
 Puts the label for the player in the correct position.
void QueuePlaceName (Uint8 pid)
 Sets the flag that indicates the given player's name label needs to be redrawn.
void QueuePlaceShell (Uint8 pid)
 Sets the flag that indicates the given player's shell needs to be redrawn.
void QueuePlaceTank (Uint8 pid)
 Sets the flag that indicates the given player's tank needs to be redrawn.
void RemoveShell (Uint8 pid)
 Removes the flag that indicates the given player's shell needs to be redrawn.
void RenderGame ()
static void RotateTank (Player *p, Sint16 rot)
 Roates a player's tank.
void SpawnTank (Player *p)
 Spawns the given tank.
void UpdatePlayers (Uint32 time)
 Updates all player data to the present time.

Variables

static Uint32 batchNameDraw [((((32)%(32)) > 0)?((int)(32)/(32)+1):((int)(32)/(32)))] = { 0 }
 A set of bit flags indicating which player's name labels need to be placed by the renderer.
static Uint32 batchShellDraw [((((32)%(32)) > 0)?((int)(32)/(32)+1):((int)(32)/(32)))] = { 0 }
 A set of bit flags indicating which player's shells need to be placed by the renderer.
static Uint32 batchTankDraw [((((32)%(32)) > 0)?((int)(32)/(32)+1):((int)(32)/(32)))] = { 0 }
 A set of bit flags indicating which player's tanks need to be placed by the renderer.
static const Sint32 motionTable [16][2]
 A table containing the x and y movement deltas based on the rotation value.
static const float normalTable [16][2]
 A table containing normal vectors based on the rotation value.
static unsigned int oldClosest = 0xFFFFFFFF
 The last computed closest distance from the player's tank to any other moving tank.


Detailed Description

Game specific code.

Author:
Jeff Jackowski (jeffj@ro.com)
Copyright (C) 2007 Jeff Jackowski

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Or visit their website at: http://www.gnu.org/

Definition in file game.c.


Function Documentation

static void FixTankCollision ( Player p  )  [static]

Attempts to correct a collision between this tank and another tank.

Call the function for each colliding tank/player.

Parameters:
p A player who's tank is colliding with another tank.
Author:
Jeff Jackowski

Definition at line 673 of file game.c.

References Player_t::flags, MoveTank(), NETSTATE_SERVER, networkState, PLAYER_BACKWARD, PLAYER_FORWARD, PLAYER_ROTLEFT, PLAYER_ROTRIGHT, PLAYER_UPDATE_TANK, and RotateTank().

Here is the call graph for this function:


Variable Documentation

unsigned int oldClosest = 0xFFFFFFFF [static]

The last computed closest distance from the player's tank to any other moving tank.

Used to attenuate the volumne of the sound of other moving tanks.

Definition at line 154 of file game.c.

Referenced by HandleInput().


Generated on Mon May 28 04:41:39 2007 for Retro Tank Super Attack by  doxygen 1.5.2