main.cpp File Reference

#include "stdafx.h"

Include dependency graph for main.cpp:

Go to the source code of this file.

Namespaces

namespace  std

Functions

int main (int argc, char **argv)
 program entry-point
int PlayGame (CWorld *ThisWorld)
 in-game loop
CWorldInitGame (int level)
 initialize game world with a level
int KillGame (CWorld *ThisWorld)
 remove a CWorld object
void initWidgets ()
 initialize GUI widgets
void debugText (const char *text)
float DegreesToRadians (float deg)
 convert degrees to radians
float RadiansToDegrees (float rad)
 convert radians to degrees
int ToggleFullScreen (GameState *State)

Variables

GameStateDasGame
SDL_Surface * screen
SDL_Event event
gcn::OpenGLGraphics * graphics
gcn::OpenGLSDLImageLoader * imageLoader
gcn::Gui * gui
gcn::ImageFont * font_small
gcn::ImageFont * font_big
gcn::Container * top


Function Documentation

void debugText ( const char *  text  ) 

Definition at line 749 of file main.cpp.

References font_small, graphics, SCREEN_HEIGHT, and SCREEN_WIDTH.

float DegreesToRadians ( float  deg  ) 

Definition at line 767 of file main.cpp.

References PI.

Referenced by DrawCircle(), DrawDisc(), DrawStar(), GameLogicFire(), PlayGame(), and UpdateBody().

Here is the caller graph for this function:

CWorld* InitGame ( int  level  ) 

Initialize this CWorld object with level data. The 'level' parameter passed in to this function is used to form a filename. This file holds the level data which is loaded and used to initialize the game world object. This function also performs other initialization on the world object in order to prepare it for the in-game loop.

Todo:
Enhance the level file format to include initialization parameters.

Definition at line 652 of file main.cpp.

References CWorld::AddObject(), ANIMID_BROWNTANKEXPLODE, ANIMID_GREENTANKEXPLODE, ANIMID_TANKROLL, CWorld::bTakeInput, DasGame, EFFECTID_PSYSTEM, EFFECTID_TILEANIM, CObject::fAngle, CObject::fSubAngle, CWorld::fZoomBias, GameState::iBrownHandicap, CObject::iDamageSound, GameState::iGreenHandicap, CObject::iHealth, CObject::iLingerTime, CObject::iNormalAnim, CObject::iNormalAnimSpeed, CObject::iRemovalAnim, CObject::iRemovalAnimSpeed, CObject::iRemovalEffect, CObject::iRemovalEffects, CWorld::iStartingState, CObject::iTint, CWorld::LoadLevel(), CWorld::Player, CObject::Position, SOUNDID_HIT, STARTINGSTATE_IDLE, STARTINGSTATE_RUN, TINTID_ARMYBROWN, TINTID_ARMYGREEN, TYPEID_TANK, Vector::x, and Vector::y.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

void initWidgets ( void   ) 

Initialize the GUIChan widgets used in all the GUIs (main, options, etc.)

Definition at line 744 of file main.cpp.

References top.

Referenced by main(), and ToggleFullScreen().

Here is the caller graph for this function:

int KillGame ( CWorld ThisWorld  ) 

Removes a CWorld object from memory, after removing all of it's contents. This is used by the top-level loop to remove a game world after the player's game is complete, and before loading a new level.

Todo:
**IMPORTANT** Add code to delete the world data before deleting the world object! This was crashing before, so figure out why, otherwise you are sitting on a fat memory leak.

Definition at line 731 of file main.cpp.

Referenced by main().

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

This is the program's entry-point, where execution begins. All game code is called from this function, directly or indirectly. Top level initialization of the graphics, GUI, sound, and game structures is done here. The top level game loop (not the in-game loop) is also here. The top-level game loop presents the player with the main menu.

Definition at line 56 of file main.cpp.

References GameState::bAutoAdvanceLevel, Credits(), DasGame, ENABLE_SOUND, font_big, font_small, graphics, gui, HighScoreMenu(), GameState::iCurrentLevel, imageLoader, GameState::iMaxLevel, InitCollision(), InitGame(), InitGL(), InitSound(), InitTextures(), initWidgets(), KillGame(), MainMenu(), MENUID_CREDITS, MENUID_HIGHSCORES, MENUID_NULL, MENUID_OPTIONS, MENUID_QUIT, MENUID_START, MUSICID_MENU, OptionsMenu(), PlayGame(), PlayMusic(), RUN_FULLSCREEN, screen, SCREEN_HEIGHT, SCREEN_WIDTH, StopMusic(), top, and GameState::World.

Here is the call graph for this function:

int PlayGame ( CWorld ThisWorld  ) 

This function comprises the 'in-game' loop, where the player is interacting with the game world, or watching the intro / victory sequence. This function gets input from the user, calls the physics engine and game logic engine, draws the game world, the GUI, and finally swaps the backbuffer to the screen. Exiting this function means that control is passed back to the top-level loop.

Todo:
re-write timing code to use higher precision timer function than SDL provides

Definition at line 200 of file main.cpp.

References CWorld::AddEffect(), ANIMID_BROWN_HOP_IN, ANIMID_GREEN_HOP_IN, CWorld::bGameOver, CWorld::bTakeInput, DasGame, DegreesToRadians(), DoCollisions(), DrawGLScene(), DrawStripe(), EFFECTID_TILEANIM, event, CObject::fAngle, font_big, font_small, graphics, CObject::iAmmo, GameState::iBrownPlayerJoystick, CWorld::iCurrentTime, GameState::iGreenPlayerJoystick, CObject::iHealth, CObject::iInput, InitStripeAlpha(), INPUT_DOWN, INPUT_FIRE, INPUT_LEFT, INPUT_RIGHT, INPUT_UP, CWorld::iRenderStyle, CWorld::iStartingState, CWorld::musicFile, MUSICID_INGAME, CObject::ParentWorld, PhysicsUpdate(), CWorld::Player, PlayLevelMusic(), PlaySound(), CObject::Position, ProcessTileCollisions(), RemoveDeadObjects(), RENDERSTYLE_FLAT, RENDERSTYLE_PERSPECTIVE, SCREEN_HEIGHT, SCREEN_WIDTH, SOUNDID_GO, SOUNDID_READY, SOUNDID_SET, SOUNDID_VICTORY, STARTINGSTATE_GO, STARTINGSTATE_IDLE, STARTINGSTATE_READY, STARTINGSTATE_RUN, STARTINGSTATE_SET, STARTINGSTATE_VICTORY, StopMusic(), CEffect::TAnim, UpdateAnimation(), CWorld::UpdateEffects(), VRotate2D(), Vector::x, Vector::y, and Vector::z.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

float RadiansToDegrees ( float  rad  ) 

Definition at line 773 of file main.cpp.

References PI.

int ToggleFullScreen ( GameState State  ) 

brief toggle between windowed and full screen mode

This function, accessed from the game's option menu, allows the player to switch between a windowed or full-screen view of the game's video output. This function destroys and re-creates all neccessary objects required to perform this function.

Definition at line 784 of file main.cpp.

References GameState::bFullScreen, font_big, font_small, graphics, gui, imageLoader, InitGL(), InitTextures(), initWidgets(), screen, SCREEN_HEIGHT, SCREEN_WIDTH, and top.

Referenced by OptionsMenu().

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

GameState* DasGame

Definition at line 28 of file main.cpp.

Referenced by InitGame(), main(), and PlayGame().

SDL_Event event

Definition at line 34 of file main.cpp.

Referenced by GetMenuInput(), and PlayGame().

gcn::ImageFont* font_big

Definition at line 41 of file main.cpp.

Referenced by main(), PlayGame(), and ToggleFullScreen().

gcn::ImageFont* font_small

Definition at line 40 of file main.cpp.

Referenced by debugText(), main(), PlayGame(), and ToggleFullScreen().

gcn::OpenGLGraphics* graphics

Definition at line 37 of file main.cpp.

Referenced by debugText(), main(), PlayGame(), and ToggleFullScreen().

gcn::Gui* gui

Definition at line 39 of file main.cpp.

Referenced by main(), and ToggleFullScreen().

gcn::OpenGLSDLImageLoader* imageLoader

Definition at line 38 of file main.cpp.

Referenced by main(), and ToggleFullScreen().

SDL_Surface* screen

Definition at line 33 of file main.cpp.

Referenced by main(), and ToggleFullScreen().

gcn::Container* top

Definition at line 44 of file main.cpp.

Referenced by initWidgets(), main(), and ToggleFullScreen().

 

Copyright Windsor Schmidt 2006 - All rights reserved.