clooneljump/src/main.cpp
King_DuckZ 28bd73a1f7 PNG loading and major refactoring.
PNG loading is not working properly yet.
2014-02-21 21:51:56 +01:00

46 lines
1.4 KiB
C++

#include "CloonelJumpConfig.h"
#include "sdlmain.hpp"
#include "physicsfswrapper.hpp"
#include "gameplaysceneclassic.hpp"
#include <iostream>
#include <stdexcept>
#include <ciso646>
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[]) {
std::cout << GameName << " v" << GameVersionMajor << "." << GameVersionMinor << std::endl;
int retVal = 0;
cloonel::SDLMain sdlmain(GameName, DEF_WIN_WIDTH, DEF_WIN_HEIGHT);
try {
cloonel::PhysicsFSWrapper physfs(parArgv[0]);
physfs.Append(GAME_BASE_PATH "/resources/", "resources");
sdlmain.Init();
cloonel::GameplaySceneClassic game(&sdlmain);
RunMainLoop(game);
}
catch (const std::runtime_error& e) {
std::cerr << "Error during SDL2 initialization:\n";
std::cerr << e.what() << std::endl;
retVal = 1;
}
std::cout << "Quitting now" << std::endl;
return retVal;
}