Key Press for Quit, How To?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
firefly2442
Posts: 38
Joined: Mon May 31, 2004 7:55 am
Contact:

Key Press for Quit, How To?

Post by firefly2442 »

I'm going through the tutorials and I was wondering how I could get the key press of 'Esc' or 'Q' in order to quit the demo. Is there some forcequit way? I've been giving the examples the old "three finger salute" with CTRL-ALT-DELETE. Thanks. :)
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

The techdemo has an example to use escape but involves the use of other .h files so it's complicated (at least for me).

I think there must be a way to assign the quit function straight to a key, just like WASD navigation for the camera.

I need that too!
Image
Peter Müller
Posts: 292
Joined: Sun Mar 14, 2004 5:28 pm
Location: Germany
Contact:

Post by Peter Müller »

I think there must be a way to assign the quit function straight to a key
Don't think so. But why don't you just use the KEY_INPUT event of the EventReceiver (max. 10 lines of code)?
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
Asterisk Man

simple way (with a global var tho)

Post by Asterisk Man »

here's what I use for a few progs:

bool exit = false;

class MyEventReceiver: public IEventReceiver
{
virtual bool OnEvent(SEvent event)
{
switch(event.KeyInput)
{
case KEY_ESCAPE:
exit = true;
}
}
}

.
.
.
int main()
{


while(device->run() && exit == false)
{
.
.
.
}

}


fill the ...s with whatever you like, but I hope you see what i'm doing. if you already use and EventReceiver class, this should be a 5-6 line addition to your code.

Hope it helps!
Peter Müller
Posts: 292
Joined: Sun Mar 14, 2004 5:28 pm
Location: Germany
Contact:

Post by Peter Müller »

Exact. I would do it so, too.
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
Post Reply