I am trying to create a game state manager using an input manager where a gui will appear when the user presses escape in game, for some reason its not working
main.h
#ifndef MAIN_H_
#define MAIN_H_
#include <irrlicht.h>
#include <iostream>
#include <string.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
//globals
class redNovember
{
public:
// always initialize class-members in the constructor - especially set pointers to 0!
redNovember() : device(0), driver(0), smgr(0),guienv(0)
{}
IrrlichtDevice *device;
IVideoDriver* driver;
ISceneManager* smgr;
IGUIEnvironment* guienv;
ICameraSceneNode * camera;
IMetaTriangleSelector * meta;
IGPUProgrammingServices* gpu;
scene::IParticleSystemSceneNode* ps;
gui::IGUIInOutFader* fader;
void initIrrlicht();
void initFPSCamera();
void renderScene();
int shutdown();
void inputHandle();
//for the game scenes
void LoadScene(); // const chars for maps
void initSkybox(const char* up,const char* down,const char* left, const char* right, const char* front, const char* back);
void initSkydome(const char* skydomefile);
//shader stuff
void initShader();
void VertexShader(const char* VertexShaderFilename, const char* VertexShaderFunction);
void PixelShader(const char* PixelShaderFilename, const char* PixelShaderFunction);
void GeoShader(const char* GeoShaderFilename, const char* GeoShaderFunction);
void initRain();
void initFog();
void initBloom();
void initHDR();
void initSSAO();
void initBokehDOF();
//user interface and effects
bool showGameMenu;
void fadeInTransition();
void fadeOutTransition();
void showInGameMenu();
void hideInGameMenu();
//material and shader ID's
s32 bloomMaterial;
s32 bokehDOFMaterial;
//s32 CgExampleMaterialType;
//for shaders
// You can put any other variables you want in here.
// For example driver, scenemanger although you can also always get them from device
// Note that the clean solution is making variables private and use public
// get-functions to access them from other classes as you can see when looking at Irrlicht classes.
// You can for example also create a function like that:
//irr::scene::ISceneManager* getSceneManager() const { return device ? device->getSceneManager() : 0; }
};
// every other global you would need can instead of being global just be put in here.
class MyEventReceiver : public IEventReceiver
{
public:
// This is the one method that we have to implement
virtual bool OnEvent(const SEvent& event)
{
// Remember whether each key is down or up
if (event.EventType == irr::EET_KEY_INPUT_EVENT)
KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
return false;
}
// This is used to check whether a key is being held down
virtual bool IsKeyDown(EKEY_CODE keyCode) const
{
return KeyIsDown[keyCode];
}
MyEventReceiver()
{
for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
KeyIsDown[i] = false;
}
private:
// We use this array to store the current state of each key
bool KeyIsDown[KEY_KEY_CODES_COUNT];
};
#endif
main.cpp
#include "main.h"
#include "luamanager.h"
#include "physicsmanager.h"
LuaManager * LUA = new LuaManager;
//newtonManager* PHYS = new newtonManager;
redNovember* SYS = new redNovember;
MyEventReceiver receiver;
int redNovember::shutdown()
{
LUA->DropLua();
delete LUA;
//PHYS->drop();
device->drop();
//delete PHYS;
delete SYS;
return 0;
}
int main()
{
SYS->initIrrlicht();
//PHYS->init();
SYS->LoadScene();
SYS->initShader();
SYS->initFPSCamera();
//SYS->initRain();
SYS->initFog();
LUA->loadScript("assets/scripts/test.lua");
///put main shit in here
//put gui loop here
SYS->initSkydome("assets/skydome/storm1.jpg");
/*
SYS->initSkybox("assets/skybox/citystorm/up.jpg",
"assets/skybox/citystorm/down.jpg",
"assets/skybox/citystorm/left.jpg",
"assets/skybox/citystorm/right.jpg",
"assets/skybox/citystorm/back.jpg",
"assets/skybox/citystorm/front.jpg");*/
SYS->renderScene();
SYS->shutdown();
}
void redNovember::initIrrlicht()
{
device = createDevice(EDT_OPENGL, dimension2d<u32>(800, 600), 32,
false, false, true, 0);
device->setWindowCaption(L"Project: Red November");
driver = device->getVideoDriver();
smgr = device->getSceneManager();
guienv = device->getGUIEnvironment();
device->getCursorControl()->setVisible(false); //hide cursor
fader = device->getGUIEnvironment()->addInOutFader();
// Then create the event receiver, giving it that context structure.
// And tell the device to use our custom event receiver.
}
void redNovember::renderScene()
{
int lastFPS = -1;
while(device->run())
{
inputHandle(); //input handler
if(!device->isWindowActive())
{
//add pause functions here
}
if (device->isWindowActive())
{
driver->beginScene(true, true, video::SColor(255,200,200,200));
smgr->drawAll();
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"[";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
else
device->yield();
}
}
void redNovember::inputHandle()
{
//menu key handler
if(receiver.IsKeyDown(irr::KEY_ESCAPE))
showGameMenu = true;
//menu shit
if (showGameMenu = true)
{
SYS->showInGameMenu();
}
else
SYS->hideInGameMenu();
};
gui.cpp
#include "main.h"
void redNovember::fadeInTransition()
{
fader->setColor(video::SColor(0,0,0,0));
fader->fadeOut(4000);
}
void redNovember::fadeOutTransition()
{
fader->setColor(video::SColor(0,0,0,0));
fader->fadeIn(4000);
}
void redNovember::showInGameMenu()
{
std::cout << "on" << std::endl;
}
void redNovember::hideInGameMenu()
{
std::cout << "off" << std::endl;
}
at the moment it should spam off on the output window and then spam on when the escape key is pressed... the output only spams on though






