2010-04-05 23:38:59 +02:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "Engine.h"
|
|
|
|
|
|
|
|
#include "Controller.h"
|
|
|
|
#include "View.h"
|
|
|
|
#include "Model.h"
|
|
|
|
#include "Physics.h"
|
|
|
|
#include "EntityFactory.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
int main (int argc, char* argv[]) {
|
|
|
|
cout << "Game Start" << endl;
|
|
|
|
|
|
|
|
Engine::Engine engine;
|
|
|
|
|
|
|
|
engine.SetEntityFactory (new asteroids::EntityFactory);
|
|
|
|
engine.SetController (new asteroids::Controller);
|
|
|
|
engine.SetModel (new asteroids::Model);
|
|
|
|
engine.SetPhysics (new asteroids::Physics);
|
|
|
|
engine.SetView (new asteroids::View);
|
|
|
|
|
2010-04-08 20:04:39 +02:00
|
|
|
SetLogPrintLevel (Engine::LogLevelMessage);
|
2010-04-08 19:34:57 +02:00
|
|
|
Engine::SetLogFilename ("game.log");
|
2010-04-05 23:38:59 +02:00
|
|
|
|
|
|
|
if (engine.Init (argc, argv) != 0) {
|
|
|
|
cout << "Could not start engine!" << endl;
|
|
|
|
exit (-1);
|
|
|
|
}
|
2010-04-08 20:04:39 +02:00
|
|
|
|
|
|
|
// Load the icon
|
|
|
|
Uint32 colorkey;
|
|
|
|
SDL_Surface *image = NULL;
|
|
|
|
image = SDL_LoadBMP("./data/textures/icon.bmp");
|
|
|
|
if (!image)
|
|
|
|
Engine::LogWarning("Could not load icon: ./data/textures/icon.bmp");
|
|
|
|
else
|
|
|
|
SDL_WM_SetIcon(image,NULL);
|
|
|
|
|
|
|
|
SDL_WM_SetCaption("Asteroids -Leaked TechDemo-","Asteroids -Leaked TechDemo-");
|
2010-04-05 23:38:59 +02:00
|
|
|
|
|
|
|
engine.GetView()->SetGridSize (8,8);
|
|
|
|
dynamic_cast<asteroids::Physics*>(engine.GetPhysics())->SetWorldSize (28, 20);
|
|
|
|
|
2010-11-28 01:13:45 +01:00
|
|
|
// run the default commands and load the configuration
|
2010-04-06 00:12:26 +02:00
|
|
|
Engine::RunCommand ("exec asteroids.rc");
|
2010-11-28 01:13:45 +01:00
|
|
|
Engine::RunCommand ("exec config.rc");
|
2010-11-28 00:20:58 +01:00
|
|
|
|
2010-04-05 23:38:59 +02:00
|
|
|
engine.MainLoop ();
|
|
|
|
|
2010-11-28 01:13:45 +01:00
|
|
|
// save the configuration
|
|
|
|
std::ofstream config_file ("config.rc");
|
|
|
|
config_file << "set effects_volume " << Engine::GetEffectsVolume() << std::endl;
|
|
|
|
config_file << "set music_volume " << Engine::GetMusicVolume() << std::endl;
|
|
|
|
config_file.close();
|
|
|
|
|
2010-04-08 20:04:39 +02:00
|
|
|
SDL_WM_SetIcon(NULL,NULL);
|
|
|
|
SDL_FreeSurface (image);
|
|
|
|
|
2010-04-05 23:38:59 +02:00
|
|
|
engine.Destroy ();
|
|
|
|
|
|
|
|
cout << "Game Quit" << endl;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|