Astornia demo

Discussion about everything. New games, 3d math, development tips...
FleshCrawler
Posts: 108
Joined: Fri Aug 22, 2003 1:04 pm
Location: Kerkrade, Netherlands
Contact:

Astornia demo

Post by FleshCrawler »

well, its nothing big yet, but it shows what i'm working on recently, i actually just started to get a bit serious.

but plz read the readme :)

http://home.wanadoo.nl/batavier.kerkrad ... 050Rel.zip

well, you can find it on that location, and i hope you will like it.

and i hope to get some tips how i can improve my programming skills :)
puh
Posts: 356
Joined: Tue Aug 26, 2003 3:53 pm

Post by puh »

Nice monster in fire!
Saalen
Posts: 51
Joined: Thu Sep 04, 2003 7:49 am
Location: Germany
Contact:

Re: Astornia demo

Post by Saalen »

FleshCrawler wrote: and i hope to get some tips how i can improve my programming skills :)

Code: Select all

node2->setMaterialTexture( 0, driver->getTexture("data/zombie/zombie.jpg") );
		if (node2 !=NULL){
			LogWrite("Mesh 2 Texture Loaded...\n"); 
		}
		else
		{
			LogWrite("Mesh 2 Texture Loading Failed (File not found)...\n");
		}
Thats not what you want, better check the result of the getTexture() call:

Code: Select all

ITexture* t=driver->getTexture("data/zombie/zombie.jpg");
		if (t !=NULL){
			LogWrite("Mesh 2 Texture Loaded...\n"); 
                      node2->setMaterialTexture( 0,  t);
		}
		else
		{
			LogWrite("Mesh 2 Texture Loading Failed (File not found)...\n");
		}


Exiting with ESC does not work, because you forgot to call device->closeDevice() before dropping it.
FleshCrawler
Posts: 108
Joined: Fri Aug 22, 2003 1:04 pm
Location: Kerkrade, Netherlands
Contact:

Post by FleshCrawler »

i updated the code, tnx :)

but on the ESC part, i tried everything, just doesnt seem to work in any way. i dont what it could be.

if i use closedevice first i get:
First-chance exception in Astornia.exe: 0xC0000005: Access Violation.

and when using drop i get:

-> --ReferenceCounter;

in IUnknown.h

i'm thinking of dropping that part of code. and just use Alt F4 instead
Saalen
Posts: 51
Joined: Thu Sep 04, 2003 7:49 am
Location: Germany
Contact:

Post by Saalen »

Hi,

You drop the device a second time here:

Code: Select all

//Drop the Irrlicht device.
	device->drop();
		if (device !=NULL){
	LogWrite("Device Destruction Succes...\n"); 
	}
	else
	{
		LogWrite("Device Destruction Failed...\n");
	}
	//return to windows
	return 0;
This does not work, sind there is only one instanc of the device.

Removing drop() in onEvent() will help.
The drop after the run()-loop will be called anyway.
FleshCrawler
Posts: 108
Joined: Fri Aug 22, 2003 1:04 pm
Location: Kerkrade, Netherlands
Contact:

Post by FleshCrawler »

well, i asked some friends to use the Esc-key, and i used my Laptop, it seems to work fine, only not on my PC, i guess i need to reinstall it someday, but i'm gonna update the readme.txt gonna make it a warning.

but tnx anyway for the help :)
FleshCrawler
Posts: 108
Joined: Fri Aug 22, 2003 1:04 pm
Location: Kerkrade, Netherlands
Contact:

Post by FleshCrawler »

Hello, me again, maybe getting up this threat, but its about the same demo, i totally rewrote it. and now i again got a problem with the esc-key

i took the code right out of the Techdemo...

in CDemo.h

Code: Select all

class CDemo : public IEventReceiver
{
public:
...
	virtual bool OnEvent(SEvent event);
private:
...
};
and then as following in CDemo.cpp

Code: Select all

bool CDemo::OnEvent(SEvent event)
{
	if (event.EventType == EET_KEY_INPUT_EVENT &&
		event.KeyInput.Key == KEY_ESCAPE &&
		event.KeyInput.PressedDown == false)
	{
		// user wants to quit.
		device->closeDevice();
	}
	return false;
}
but when i hit it, nothing happens :S not closing, no error, nothing.
even changed return fucntion to true, 0, 1 and just nothing :S
I've been absent for really long, but i'm ready to reign my terror on you once again, mwuahahahahaha
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post by saigumi »

The Return doesn't matter in this case. What is important is the device->closeDevice(); This would then be caught by your game loop.

Code: Select all

while(device->run() && driver)
{
  //do stuff
}
By closing the device, device->run() == false.
Crud, how do I do this again?
FleshCrawler
Posts: 108
Joined: Fri Aug 22, 2003 1:04 pm
Location: Kerkrade, Netherlands
Contact:

Post by FleshCrawler »

could you please explain this in a bit more details?

i dont exactly know what you mean, Tnx in Advance :)
I've been absent for really long, but i'm ready to reign my terror on you once again, mwuahahahahaha
Sfin
Posts: 13
Joined: Wed Oct 15, 2003 9:13 pm

Post by Sfin »

In your main.cpp you have a loop that looks like this, which is the main game loop:

Code: Select all


while( device->run() )
{

//code goes here

}

device->drop();
return 0;

When you call device->closeDevice(), that sets device->run() to return a false thus exiting from the game while loop, and calling device->drop(), and ending the program.

That is just a brief explanation. If you need a better explanation I can look through the source code of Irrlicht, and provide an explanation of what the code does exactly step by step.
FleshCrawler
Posts: 108
Joined: Fri Aug 22, 2003 1:04 pm
Location: Kerkrade, Netherlands
Contact:

Post by FleshCrawler »

i could also get my code online, so u might check that out, and explain then what i'm doing wrong :) thats not a big problem :)
I've been absent for really long, but i'm ready to reign my terror on you once again, mwuahahahahaha
Sfin
Posts: 13
Joined: Wed Oct 15, 2003 9:13 pm

Post by Sfin »

Yeah that would make it a lot easier to debug the code if you post the source. I am just starting to learn Game programming and the irrlicht engine, so I am too a beginer.

Also in my above post I was just explaining what device->closeDevice() does.

One more thing:

in the OnEvent code that you posted try putting this:

std::cout << "device->closeDevice() is being called" << endl;

just before the device->closeDevice(); call.

Then when you click on the ESC key check the command prompt window, which opens when you run your demo to see if that message is printed. IT might be that it isn't passing the if statement.

That way you are making sure that your program is actually calling the closeDevice() function.

P.S. make sure to include <iostream> in the CDemo class to be able to use cout.
FleshCrawler
Posts: 108
Joined: Fri Aug 22, 2003 1:04 pm
Location: Kerkrade, Netherlands
Contact:

Post by FleshCrawler »

well,i just uploaded the source to

http://home.wanadoo.nl/batavier.kerkrad ... tornia.zip

so, i hope this makes it a lot easier :)
I've been absent for really long, but i'm ready to reign my terror on you once again, mwuahahahahaha
Sfin
Posts: 13
Joined: Wed Oct 15, 2003 9:13 pm

Post by Sfin »

OK I checked your source code, and here is what I did to make the ESC key work.


IN CDemo.cpp:


CHANGE

Code: Select all


void CDemo::run()
{
	device = createDevice(driverType,
		resolutionType , 16, fullscreen);


        ....... More code here

}


TO

Code: Select all


void CDemo::run()
{
	device = createDevice(driverType,
		resolutionType , 16, fullscreen, false, this);


        ....... More code here

}


You forgot to add the CDemo object as an Event reciever for the device you created, so even though you were clicking the ESC key, the device was not getting the message.
Sfin
Posts: 13
Joined: Wed Oct 15, 2003 9:13 pm

Post by Sfin »

Also in the OnEvent in the CDemo.cpp this doesn't work:

Code: Select all


if (device->closeDevice !=NULL){
	LogWrite("Demo Successfully Exit...\n");

Because device->closeDevice() is void so it doesn't return anything. I think something like this might work:

Code: Select all


if ( device->run() ){
	LogWrite("Demo Successfully Exit...\n");

Because is device->closeDevice() is called device->run() will return a FALSE
Post Reply