clooneljump/src/main.cpp

67 lines
2.2 KiB
C++
Raw Normal View History

2014-02-25 10:04:16 +00:00
/*
Copyright 2014 Michele "King_DuckZ" Santullo
This file is part of CloonelJump.
CloonelJump is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
CloonelJump is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with CloonelJump. If not, see <http://www.gnu.org/licenses/>.
*/
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-03-06 10:43:28 +00:00
#include "vector.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-03-06 10:43:28 +00:00
cloonel::SDLMain sdlmain(GameName, cloonel::ushort2(DEF_WIN_WIDTH, DEF_WIN_HEIGHT), cloonel::ushort2(REFERENCE_WIDTH, REFERENCE_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
}