Problems with my "gamestate"-variable
Posted: Wed Nov 16, 2005 8:43 pm
Code: Select all
//Including the Irrlicht Engine (http://irrlicht.sourceforge.net/) and other stuff
#include <irrlicht.h>
#include <stdio.h>
#include <iostream>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#pragma comment(lib, "Irrlicht.lib")
int gamestate = 1;
IrrlichtDevice *device = 0;
class MyEventReceiver : public IEventReceiver
{
public:
bool OnEvent(SEvent event)
{
if(gamestate=1)
{
if (event.EventType == EET_KEY_INPUT_EVENT)
{
gamestate=2;
}
return false;
}
if(gamestate=2)
{
if (event.EventType == EET_KEY_INPUT_EVENT)
{
if (event.KeyInput.Key == KEY_KEY_Q)
{
gamestate=0;
return true;
}
}
return false;
}
}
};
int main()
{
//Create Device
device = createDevice(video::EDT_OPENGL,
core::dimension2d<s32>(1024, 768), 32, true, true, false, 0);
if (device==0)
{
return false;
}
//Set GUI
IGUIEnvironment* env = device->getGUIEnvironment();
//Create Video Driver
IVideoDriver* driver = device->getVideoDriver();
//Intialize EventReciver
MyEventReceiver receiver;
device->setEventReceiver(&receiver);
//Set Window Title
device->setWindowCaption(L"Age of War");
while(device->run()&&driver)
{
//----------------Quit------------//
while(gamestate=0)
{
device -> drop();
}
//----------------Intro-----------//
while(gamestate=1)
{
driver->beginScene(true, true, SColor(0,0,0,0));
env->drawAll();
driver->endScene();
gamestate=2;//Change to Menu
}
//----------------Menu------------//
while(gamestate=2)
{
core::stringw str = L"FPS: ";
str += driver->getFPS();
env->addStaticText(str.c_str(), rect<s32>(900,720,1024,768), true, true);
driver->beginScene(true, true, SColor(0,0,0,0));
env->drawAll();
driver->endScene();
//ToDo: Design and UI
}
//---------------Game------------//
while(gamestate=3)
{
//ToDo: Everything
}
}
}
greets,
halan