clooneljump/src/main.cpp

47 lines
1.4 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 "physicsfswrapper.hpp"
#include "gameplaysceneclassic.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::GameplaySceneClassic& parGame) {
parGame.Prepare();
do {
parGame.Exec();
} while (not parGame.WantsToQuit());
parGame.Destroy();
}
} //unnamed namespace
///----------------------------------------------------------------------------
///following http://twinklebeardev.blogspot.co.uk/2012/07/lesson-1-hello-world.html
///----------------------------------------------------------------------------
int main (int, 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 {
cloonel::PhysicsFSWrapper physfs(parArgv[0]);
physfs.Append(GAME_BASE_PATH "/resources/", "resources");
2014-02-08 22:11:26 +00:00
sdlmain.Init();
cloonel::GameplaySceneClassic game(&sdlmain);
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
}