00001 #include "irrlicht.h"
00002 #include "debug.h"
00003 #include "statemachine.h"
00004 #include "statemenu.h"
00005 #include "stateflocksimulation.h"
00006 #include "stateclose.h"
00007 #include "stateterrain.h"
00008 #include "statetornado.h"
00009 #include "startup.h"
00010 #include "main.h"
00011
00012 using namespace irr;
00013 using namespace core;
00014
00015 Debug* dbg;
00016 ITimer* timer;
00017 StateMachine* sm;
00018
00019 u32 getDeltaTime()
00020 {
00021
00022 static u32 lastTime = timer->getRealTime();
00023
00024 u32 dt = timer->getRealTime() - lastTime;
00025 lastTime += dt;
00026
00027 return dt;
00028 }
00029
00030 int main()
00031 {
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 StartUpParameters param;
00044
00045 IrrlichtDevice* device;
00046 device = createDevice(param.driverType, param.screen, param.colorBitDepth, param.fullScreen);
00047 if (! device)
00048 {
00049 printf("ERROR cannot create device with parameter:\n");
00050 printf("param fullScreen: %i\n", param.fullScreen);
00051 printf("param driverType: %i\n", param.driverType);
00052 printf("param screen: %i x %i\n", param.screen.Width, param.screen.Height);
00053 printf("param colorBitDepth: %i\n", param.colorBitDepth);
00054 return 1;
00055 }
00056 device->setWindowCaption(L"Swarm");
00057
00058 dbg = new Debug(device, "dbg.txt", rect<s32>(10, 10, 150, 200));
00059 dbg->log("App start");
00060
00061 timer = device->getTimer();
00062
00063 sm = new StateMachine(device);
00064
00065 State* closeS = new StateClose("STATE_CLOSE", device);
00066 sm->addState(closeS);
00067 State* menuS = new StateMenu("STATE_MENU", device);
00068 sm->addState(menuS);
00069 State* flockS = new StateFlockSimulation("STATE_FLOCKSIMULATION", device);
00070 sm->addState(flockS);
00071 State* terrainS = new StateTerrain("STATE_TERRAIN", device);
00072 sm->addState(terrainS);
00073 State* tornadoS = new StateTornado("STATE_TORNADO", device);
00074 sm->addState(tornadoS);
00075
00076 sm->startWith(menuS);
00077
00078 while(device->run())
00079 {
00080 dbg->update();
00081 sm->update(getDeltaTime());
00082 }
00083
00084 delete closeS;
00085 delete menuS;
00086 delete flockS;
00087 delete terrainS;
00088 delete tornadoS;
00089 delete sm;
00090 dbg->log("App end");
00091 delete dbg;
00092 device->drop();
00093
00094 return 0;
00095 }
00096