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"
|
2014-02-12 23:01:29 +00:00
|
|
|
#include "physicsfswrapper.hpp"
|
2014-02-21 20:28:34 +00:00
|
|
|
#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>
|
2014-02-09 20:15:43 +00:00
|
|
|
#include <ciso646>
|
2014-01-09 23:04:39 +00:00
|
|
|
|
2014-02-09 00:19:40 +00:00
|
|
|
namespace {
|
|
|
|
///-------------------------------------------------------------------------
|
|
|
|
///-------------------------------------------------------------------------
|
2014-02-21 20:28:34 +00:00
|
|
|
void RunMainLoop (cloonel::GameplaySceneClassic& parGame) {
|
2014-02-21 20:51:56 +00:00
|
|
|
parGame.Prepare();
|
2014-02-09 00:19:40 +00:00
|
|
|
do {
|
2014-02-21 20:28:34 +00:00
|
|
|
parGame.Exec();
|
2014-02-09 20:15:43 +00:00
|
|
|
} while (not parGame.WantsToQuit());
|
2014-02-21 20:51:56 +00:00
|
|
|
parGame.Destroy();
|
2014-02-09 00:19:40 +00:00
|
|
|
}
|
|
|
|
} //unnamed namespace
|
|
|
|
|
2014-02-08 19:25:30 +00:00
|
|
|
///----------------------------------------------------------------------------
|
|
|
|
///following http://twinklebeardev.blogspot.co.uk/2012/07/lesson-1-hello-world.html
|
|
|
|
///----------------------------------------------------------------------------
|
2014-02-21 20:51:56 +00:00
|
|
|
int main (int, char* parArgv[]) {
|
2014-01-09 23:04:39 +00:00
|
|
|
std::cout << GameName << " v" << GameVersionMajor << "." << GameVersionMinor << std::endl;
|
|
|
|
|
2014-02-12 23:01:29 +00:00
|
|
|
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 {
|
2014-02-21 20:51:56 +00:00
|
|
|
cloonel::PhysicsFSWrapper physfs(parArgv[0]);
|
|
|
|
physfs.Append(GAME_BASE_PATH "/resources/", "resources");
|
2014-02-12 23:01:29 +00:00
|
|
|
|
2014-02-08 22:11:26 +00:00
|
|
|
sdlmain.Init();
|
2014-02-12 23:01:29 +00:00
|
|
|
|
2014-02-21 20:28:34 +00:00
|
|
|
cloonel::GameplaySceneClassic game(&sdlmain);
|
2014-02-12 23:01:29 +00:00
|
|
|
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;
|
2014-02-12 23:01:29 +00:00
|
|
|
retVal = 1;
|
2014-01-09 23:04:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::cout << "Quitting now" << std::endl;
|
2014-02-12 23:01:29 +00:00
|
|
|
return retVal;
|
2014-01-09 23:04:39 +00:00
|
|
|
}
|