#endif
}
+using namespace Game;
+
static bool load_image(const char * fname, TGAImageRec & tex);
static bool load_png(const char * fname, TGAImageRec & tex);
static bool load_jpg(const char * fname, TGAImageRec & tex);
NULL
};
-void DrawGL(Game & game);
-
-Boolean SetUp (Game & game);
-void DoUpdate (Game & game);
+Boolean SetUp ();
+void DoUpdate ();
void CleanUp (void);
Boolean gDone = false;
-Game * pgame = 0;
-
#ifndef __MINGW32__
static int _argc = 0;
static char **_argv = NULL;
//~ pgame->LoadScreenTexture();
}
-static void sdlEventProc(const SDL_Event &e, Game &game)
+static void sdlEventProc(const SDL_Event &e)
{
switch(e.type) {
case SDL_MOUSEMOTION:
- game.deltah += e.motion.xrel;
- game.deltav += e.motion.yrel;
+ deltah += e.motion.xrel;
+ deltav += e.motion.yrel;
break;
case SDL_KEYDOWN:
static Point gMidPoint;
-Boolean SetUp (Game & game)
+Boolean SetUp ()
{
char string[10];
slomofreq=8012;
numplayers=1;
- DefaultSettings(game);
+ DefaultSettings();
if (!SDL_WasInit(SDL_INIT_VIDEO))
if (SDL_Init(SDL_INIT_VIDEO) == -1)
fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError());
return false;
}
- if(!LoadSettings(game)) {
+ if(!LoadSettings()) {
fprintf(stderr, "Failed to load config, creating default\n");
- SaveSettings(game);
+ SaveSettings();
}
if(kBitsPerPixel!=32&&kBitsPerPixel!=16){
kBitsPerPixel=16;
screenwidth=width;
screenheight=height;
- game.newdetail=detail;
- game.newscreenwidth=screenwidth;
- game.newscreenheight=screenheight;
+ newdetail=detail;
+ newscreenwidth=screenwidth;
+ newscreenheight=screenheight;
- game.InitGame();
+ InitGame();
return true;
}
-static void DoMouse(Game & game)
+static void DoMouse()
{
- if(mainmenu|| ( (abs(game.deltah)<10*realmultiplier*1000) && (abs(game.deltav)<10*realmultiplier*1000) ))
+ if(mainmenu|| ( (abs(deltah)<10*realmultiplier*1000) && (abs(deltav)<10*realmultiplier*1000) ))
{
- game.deltah *= usermousesensitivity;
- game.deltav *= usermousesensitivity;
- game.mousecoordh += game.deltah;
- game.mousecoordv += game.deltav;
- if (game.mousecoordh < 0)
- game.mousecoordh = 0;
- else if (game.mousecoordh >= kContextWidth)
- game.mousecoordh = kContextWidth - 1;
- if (game.mousecoordv < 0)
- game.mousecoordv = 0;
- else if (game.mousecoordv >= kContextHeight)
- game.mousecoordv = kContextHeight - 1;
+ deltah *= usermousesensitivity;
+ deltav *= usermousesensitivity;
+ mousecoordh += deltah;
+ mousecoordv += deltav;
+ if (mousecoordh < 0)
+ mousecoordh = 0;
+ else if (mousecoordh >= kContextWidth)
+ mousecoordh = kContextWidth - 1;
+ if (mousecoordv < 0)
+ mousecoordv = 0;
+ else if (mousecoordv >= kContextHeight)
+ mousecoordv = kContextHeight - 1;
}
}
}
-void DoUpdate (Game & game)
+void DoUpdate ()
{
static float sps=200;
static int count;
DoFrameRate(1);
if(multiplier>.6)multiplier=.6;
- game.fps=1/multiplier;
+ fps=1/multiplier;
count = multiplier*sps;
if(count<2)count=2;
if(difficulty==1)multiplier*=.9;
if(difficulty==0)multiplier*=.8;
- if(game.loading==4)multiplier*=.00001;
+ if(loading==4)multiplier*=.00001;
if(slomo&&!mainmenu)multiplier*=slomospeed;
oldmult=multiplier;
multiplier/=(float)count;
- DoMouse(game);
+ DoMouse();
- game.TickOnce();
+ TickOnce();
for(int i=0;i<count;i++)
{
- game.Tick();
+ Tick();
}
multiplier=oldmult;
- game.TickOnceAfter();
+ TickOnceAfter();
/* - Debug code to test how many channels were active on average per frame
static long frames = 0;
num_channels = 0;
}
*/
- game.DrawGL();
+ if ( stereomode == stereoNone ) {
+ DrawGLScene(stereoCenter);
+ } else {
+ DrawGLScene(stereoLeft);
+ DrawGLScene(stereoRight);
+ }
}
// --------------------------------------------------------------------------
try
{
{
- Game game;
- pgame = &game;
+ newGame();
//ofstream os("error.txt");
//os.close();
//ofstream os("log.txt");
//os.close();
- if (!SetUp (game))
+ if (!SetUp ())
return 42;
- while (!gDone&&!game.quit&&(!game.tryquit))
+ while (!gDone&&!tryquit)
{
if (IsFocused())
{
// check windows messages
- game.deltah = 0;
- game.deltav = 0;
+ deltah = 0;
+ deltav = 0;
SDL_Event e;
- if(!game.isWaiting()) {
+ if(!waiting) {
// message pump
while( SDL_PollEvent( &e ) )
{
gDone=true;
break;
}
- sdlEventProc(e, game);
+ sdlEventProc(e);
}
}
// game
- DoUpdate(game);
+ DoUpdate();
}
else
{
{
// allow game chance to pause
gameFocused = false;
- DoUpdate(game);
+ DoUpdate();
}
// game is not in focus, give CPU time to other apps by waiting for messages instead of 'peeking'
}
}
-
+ deleteGame();
}
- pgame = 0;
CleanUp ();