StarTrekV3_Linux  Version3
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Pages
StartrekV3.cpp File Reference
#include <stdio.h>
#include <iostream>
#include <time.h>
#include <allegro5/allegro.h>
#include <allegro5/allegro_native_dialog.h>
#include <allegro5/allegro_image.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_audio.h>
#include <allegro5/allegro_acodec.h>
#include <map>
#include <vector>
#include "version.h"
#include "utils.h"
#include "FontManager.h"
#include "SoundManager.h"
#include "Paralax.h"
#include "Engine.h"
#include "Bullet.h"
#include "Animation.h"
#include "Universe.h"
#include "Enterprise.h"
#include "Romulan_BOP.h"
#include "Klingon_BC.h"
#include "Klingon_BOP.h"
#include "SpaceObject.h"
#include "Starbase.h"
#include "Federation_Ship.h"
#include "KeyMapper.h"
#include "Communication.h"
#include "Probe.h"
#include "Menu.h"
#include "SaveSlots.h"

Functions

void get_desktop_resolution (int a_nAdapter, int *a_pWidth, int *a_pHeighth)
 Get the desktop resolution. More...
 
void NewUniverse ()
 This function creates a new universe. More...
 
void NewSector (int a_nX, int a_nY)
 Clears the Engine, keeping the Enterprise and builds a new Playingfield from a sector in the universe. More...
 
void CheckSectorBounds ()
 Checks if the enterprise leaves this sector. More...
 
void DoKeymap ()
 Invoke a keymapping functionality so you can customize the controls. still a Rough implementation. More...
 
void DoMenu ()
 invoke menu ( not implemented yet ) More...
 
void DoGame ()
 The actual game loop. More...
 
void DoIntro ()
 Intro screen. More...
 
void DoLoadScreen ()
 screen for loading a game More...
 
void DoSaveScreen ()
 screen for saving a game More...
 
void NewGame ()
 start a new game More...
 
void SaveGame ()
 save current game More...
 
void SetupLoadScreen ()
 setup load screen More...
 
void Quit ()
 quit program More...
 
void ReturnToGame ()
 return to running game More...
 
void SaveMapping ()
 Save key mapping. More...
 
void LoadMapping ()
 Load key Mapping. More...
 
const string currentDateTime ()
 get the date and time More...
 
void LoadGame (string a_strLoadName)
 
bool InitObjects ()
 Initializes all Classes using resources for multiple instances. Sprite classes for example. More...
 
void DeInitObjects ()
 Some classes better be DeInited when using multiple resources. Allegro frees them anyway but Valgrind doesn't like it that way. More...
 
bool Setup ()
 Setup and initialize Allegro, the game Engine, Sprite Classes, Sound manager etc. More...
 
void ShutDown ()
 Shutdown and free, Engine, Paralax sprite Objects, allegro etc. More...
 
void Render ()
 Render the correct screen according to the gamestate. More...
 
void GameCycle ()
 Process a game cycle Calls the AI function of the game objects Invokes the next Communication message. More...
 
void KeyDown (int a_nKey)
 KeyDown event handler. More...
 
void KeyUp (int a_nKey)
 KeyUp event handler. More...
 
void Mouse (ALLEGRO_MOUSE_EVENT *mouse_event)
 mouse event handler More...
 
void MouseButtonDown (ALLEGRO_MOUSE_EVENT *mouse_event)
 MouseButtonDown event handler. More...
 
void MouseButtonUp (ALLEGRO_MOUSE_EVENT *mouse_event)
 MouseButtonUp event handler. More...
 
void Timer (ALLEGRO_TIMER_EVENT *timer_event)
 Timer event handler. More...
 
int main (int argc, char **argv)
 Program entry. More...
 

Variables

char g_szFileName [] = "MyGame.sav"
 
bool g_blGodMode = false
 
ALLEGRO_PATH * g_pSavePath = NULL
 General save path. More...
 
ALLEGRO_PATH * g_pScreenshotPath = NULL
 Path for screenshots. More...
 
ALLEGRO_DISPLAY * g_pDisplay = NULL
 The display for graphics... More...
 
ALLEGRO_EVENT_QUEUE * g_pEventQueue = NULL
 The event queue. More...
 
bool g_blQuit = false
 
bool g_blEscape = false
 
double g_nCyclesPerSecond = 60
 game logic cycles per second More...
 
double g_dLastTime
 last polled system time to calculate deltatime More...
 
int g_nScreenMode = MODE_MAINSCREEN
 screenmode.. what screen should be visible [Main] [Engineering] [Navigation] etc More...
 
vector< int > g_vGameState
 Gamestate stack [Menu] [Intro] [Game]. More...
 
int g_nScreenWidth
 
int g_nScreenHeight
 
ALLEGRO_TIMER * g_pTimer =0
 
Universeg_pUniverse = NULL
 Pointer to universe Object. More...
 
TKeyMapperg_pKeyMapper = NULL
 Pointer to Keymapper. More...
 
TEngineg_pEngine = NULL
 Pointer to Game Engine. More...
 
Paralaxg_pParalax = NULL
 Pointer Paralax system. More...
 
TEnterpriseg_pEnterprise = NULL
 Pointer to The enterprise ( The player !) More...
 
Communicationg_pCommunication = NULL
 Pointer to The Communication System. More...
 
TMenug_pMenu = NULL
 Pointer to the menu system. More...
 
SlotManagerg_pSlotManager = NULL
 

Detailed Description

Main source file, containing the game loop and setup and initialization functions. Also basic game rules like sector bounds checking and game state switching is implemented here.

Function Documentation

void CheckSectorBounds ( )

Checks if the enterprise leaves this sector.

Checks if the Enterprise crossed the borders of a sector If so it stores the old sector in the universe and calls void NewSector(int a_nX, int a_nY)

const string currentDateTime ( )

get the date and time

void DeInitObjects ( )

Some classes better be DeInited when using multiple resources. Allegro frees them anyway but Valgrind doesn't like it that way.

void DoGame ( )

The actual game loop.

Move everything in the engine. Free all destroyed objects. Check the sector bounds Move the paralax Draw everything.

void DoIntro ( )

Intro screen.

Handle the Introduction screen, Not implemented yet.

void DoKeymap ( )

Invoke a keymapping functionality so you can customize the controls. still a Rough implementation.

void DoLoadScreen ( )

screen for loading a game

void DoMenu ( )

invoke menu ( not implemented yet )

Handle the Menu, Not implemented yet [New Game] [Load] [Save] [Help].

void DoSaveScreen ( )

screen for saving a game

void GameCycle ( )

Process a game cycle Calls the AI function of the game objects Invokes the next Communication message.

void get_desktop_resolution ( int  a_nAdapter,
int *  a_pWidth,
int *  a_pHeighth 
)

Get the desktop resolution.

Gets the desktop resolution Currently not in use !

Parameters
inta_nAdapter Number of the screen adapter in use
int*a_pWidth OUT ScreenWidth
int*a_pHeighth OUT ScreenHeight
bool InitObjects ( )

Initializes all Classes using resources for multiple instances. Sprite classes for example.

Returns
returns true on success , false on failure
void KeyDown ( int  a_nKey)

KeyDown event handler.

Parameters
inta_nKey The key code
void KeyUp ( int  a_nKey)

KeyUp event handler.

Parameters
inta_nKey The key code
void LoadGame ( string  a_strLoadName)
void LoadMapping ( )

Load key Mapping.

int main ( int  argc,
char **  argv 
)

Program entry.

Parameters
intargc Number of program arguments ( not used yet)
char**argv Argument list ( not used yet)
void Mouse ( ALLEGRO_MOUSE_EVENT *  mouse_event)

mouse event handler

Parameters
ALLEGRO_MOUSE_EVENT* mouse_event
void MouseButtonDown ( ALLEGRO_MOUSE_EVENT *  mouse_event)

MouseButtonDown event handler.

Parameters
ALLEGRO_MOUSE_EVENT* mouse_event
void MouseButtonUp ( ALLEGRO_MOUSE_EVENT *  mouse_event)

MouseButtonUp event handler.

Parameters
ALLEGRO_MOUSE_EVENT* mouse_event
void NewGame ( )

start a new game

void NewSector ( int  a_nX,
int  a_nY 
)

Clears the Engine, keeping the Enterprise and builds a new Playingfield from a sector in the universe.

When the Enterprise enters a new sector This function builds a new playing field from the sector you just entered.

Parameters
inta_nX X position of new sector
inta_nY Y position of new sector
void NewUniverse ( )

This function creates a new universe.

Builds a new universe and sets Enterprise home position This creates a new game !

void Quit ( )

quit program

void Render ( )

Render the correct screen according to the gamestate.

void ReturnToGame ( )

return to running game

void SaveGame ( )

save current game

void SaveMapping ( )

Save key mapping.

bool Setup ( )

Setup and initialize Allegro, the game Engine, Sprite Classes, Sound manager etc.

Returns
returns true on success, false on failure
void SetupLoadScreen ( )

setup load screen

void ShutDown ( )

Shutdown and free, Engine, Paralax sprite Objects, allegro etc.

void Timer ( ALLEGRO_TIMER_EVENT *  timer_event)

Timer event handler.

Parameters
ALLEGRO_TIMER_EVENT* timer_event

Variable Documentation

bool g_blEscape = false
bool g_blGodMode = false
bool g_blQuit = false
double g_dLastTime

last polled system time to calculate deltatime

double g_nCyclesPerSecond = 60

game logic cycles per second

int g_nScreenHeight
int g_nScreenMode = MODE_MAINSCREEN

screenmode.. what screen should be visible [Main] [Engineering] [Navigation] etc

int g_nScreenWidth
Communication* g_pCommunication = NULL

Pointer to The Communication System.

ALLEGRO_DISPLAY* g_pDisplay = NULL

The display for graphics...

TEngine* g_pEngine = NULL

Pointer to Game Engine.

TEnterprise* g_pEnterprise = NULL

Pointer to The enterprise ( The player !)

ALLEGRO_EVENT_QUEUE* g_pEventQueue = NULL

The event queue.

TKeyMapper* g_pKeyMapper = NULL

Pointer to Keymapper.

TMenu* g_pMenu = NULL

Pointer to the menu system.

Paralax* g_pParalax = NULL

Pointer Paralax system.

ALLEGRO_PATH* g_pSavePath = NULL

General save path.

ALLEGRO_PATH* g_pScreenshotPath = NULL

Path for screenshots.

SlotManager* g_pSlotManager = NULL
ALLEGRO_TIMER* g_pTimer =0
Universe* g_pUniverse = NULL

Pointer to universe Object.

char g_szFileName[] = "MyGame.sav"
vector<int> g_vGameState

Gamestate stack [Menu] [Intro] [Game].