Code: Select all
//all includes
#include <irrlicht.h> //include headers
#include "IChoiceScreen.h"
using namespace irr; //include namespace
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib") //include libs
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
void StartGame(void);
int main() /// INIT GAME
{
isgf::IChoiceScreen set;
if(!set.choiceScreen())
return -1;
IrrlichtDevice *device=set.createDeviceFromMe(); // Loads Devices
IVideoDriver* driver = device->getVideoDriver(); // Loads Video Driver
ISceneManager* smgr = device->getSceneManager(); // Loads Scene Manager
IGUIEnvironment* gui = device->getGUIEnvironment();// Loads Environment
ISceneCollisionManager* collMan = smgr->getSceneCollisionManager(); //remember node
StartGame();
device->drop();
return 0;
}
but before the game loads the managers it has to read the other cpp file.. and it crashes because there is no managers for them yet.
Is there a way to get around this? StargGame links to a file called game.cpp
it starts like this
Code: Select all
#include <irrlicht.h> //include headers
#include "globals.h"
#include "device.h"
#include "gui.h"
#include "levels.h"
#include "controls.h"
void StartGame(void){
loadHarlowTown(smgr); // loads map, camera, and collision
dev->getCursorControl()->setVisible(false); // Removes Cursor
//game loop
while(dev->run())
if (dev->isWindowActive())
{
FunctionKeys();
driver->beginScene(true, true, 0);
smgr->drawAll();
gui->drawAll();
driver->endScene(); // End Scene
//gui
//FPS
int fps = driver->getFPS();
if (lastFPS != fps)
{
stringw str = L"CS";
str += driver->getName();
str += "] FPS:";
str += fps;
dev->setWindowCaption(str.c_str());
lastFPS = fps;
}
stringw drivrtype = L"Driver Type: ";
drivrtype += driver->getName();
gui->addStaticText(drivrtype.c_str(),rect<s32>(10,10,260,22), true);
ShowGUI();
}
dev->drop();
return 0;
}
thanks,
nathan
[/code]