Newbie question

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
finky45
Posts: 1
Joined: Sun Jan 20, 2008 3:31 pm

Newbie question

Post by finky45 »

Hey folks,

I'm trying to implement Irrlicht for the first time in my already existing framework for a game which is maybe 25% complete. If it means anything, I've been working with SDL.

I separate my game functions in 3 classes: Input, Logic, and Render so far. they are created in main(), and then each is called in a the game loop (Input->perform, logic->perform etc...)

i have created an IrrlichtDevice pointer in main, and I'm assigning in the render function. It's probably a bad thing but I don't know for sure yet. I am trying to keep the game functions separate as much as I can.

My problem is, that after I implemented the first tutorial in my Render class, I can close the window created by Irrlicht, by my game still runs in the background.

I was wondering is there a way to check if the "x" has been pressed in the window, so i can tell my main() that the game is closing?
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Re: Newbie question

Post by greenya »

finky45 wrote: I was wondering is there a way to check if the "x" has been pressed in the window, so i can tell my main() that the game is closing?
If user clicks "X" or uses key combination (alt+f4), than irrDevice->run() (that is used in while() condition in the main game loop) will return false.
sfncook
Posts: 36
Joined: Sun Jul 01, 2007 6:32 pm

Post by sfncook »

FYI: I create only one instance of an IrrlichtDevice and extern it (global) for other classes to use. Totally lame use of globals, I'm sure. But it's easy and I really haven't had any problems with it yet.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You have to return the value from device->run into your game loop and check its value.
Post Reply