clooneljump/src/main.cpp

52 lines
1.5 KiB
C++
Raw Normal View History

2014-01-09 23:04:39 +00:00
#include "CloonelJumpConfig.h"
2014-02-08 22:11:26 +00:00
#include "sdlmain.hpp"
#include "game.hpp"
#include "physicsfswrapper.hpp"
2014-02-08 22:11:26 +00:00
#include <iostream>
2014-01-09 23:04:39 +00:00
#include <stdexcept>
#include <ciso646>
2014-01-09 23:04:39 +00:00
namespace {
///-------------------------------------------------------------------------
///-------------------------------------------------------------------------
void RunMainLoop (cloonel::Game& parGame) {
float totalElapsed = 0.0f;
do {
const float delta = parGame.Exec();
totalElapsed += delta;
} while (not parGame.WantsToQuit());
}
} //unnamed namespace
///----------------------------------------------------------------------------
///following http://twinklebeardev.blogspot.co.uk/2012/07/lesson-1-hello-world.html
///----------------------------------------------------------------------------
int main (int parArgc, char* parArgv[]) {
2014-01-09 23:04:39 +00:00
std::cout << GameName << " v" << GameVersionMajor << "." << GameVersionMinor << std::endl;
int retVal = 0;
2014-02-08 22:11:26 +00:00
cloonel::SDLMain sdlmain(GameName, DEF_WIN_WIDTH, DEF_WIN_HEIGHT);
2014-01-09 23:04:39 +00:00
try {
#if defined(NDEBUG)
cloonel::PhysicsFSWrapper physfs(parArgc[0]);
#else
cloonel::PhysicsFSWrapper physfs(GAME_BASE_PATH);
#endif
physfs.Append("resources", "resources");
2014-02-08 22:11:26 +00:00
sdlmain.Init();
cloonel::Game game(&sdlmain);
game.Prepare();
RunMainLoop(game);
2014-01-09 23:04:39 +00:00
}
catch (const std::runtime_error& e) {
std::cerr << "Error during SDL2 initialization:\n";
std::cerr << e.what() << std::endl;
retVal = 1;
2014-01-09 23:04:39 +00:00
}
std::cout << "Quitting now" << std::endl;
return retVal;
2014-01-09 23:04:39 +00:00
}