Key Action Help

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
M.Irr
Posts: 11
Joined: Thu Dec 20, 2007 6:54 pm

Key Action Help

Post by M.Irr »

hi,
i've a little problem. I am going to make a FSPShooter and I think i understand the basics of Irrlicht. But I want to make a action when i Press a Key. Then I want that this:

Code: Select all

node = smgr->addLightSceneNode(0, core::vector3df(0,0,0), 
		video::SColorf(1.0f, 0.6f, 0.7f, 1.0f), 600.0f);
	scene::ISceneNodeAnimator* anim = 0;
	anim = smgr->createFlyStraightAnimator(
		core::vector3df(camera->getPosition().X,camera->getPosition().Y,camera->getPosition().Z),
		core::vector3df(
		(cos((camera->getRotation().X)*(3,141592654/180))*100+camera->getPosition().X),
		(sin((camera->getRotation().Y)*(3,141592654/180))*100+camera->getPosition().Y),
		0),250.0f,true);
	node->addAnimator(anim);
	anim->drop();

	// attach billboard to light

	node = smgr->addBillboardSceneNode(node, core::dimension2d<f32>(50, 50));
	node->setMaterialFlag(video::EMF_LIGHTING, false);
	node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
	node->setMaterialTexture(0,	driver->getTexture("../../media/particlewhite.bmp"));
runs.
But how could I make that my problem is that the variables and other object got create in the main class and I think the event receiver must be write before that. Please Help me.
M.Irr

PS:My english is really terrible I know.
M.Irr
Posts: 11
Joined: Thu Dec 20, 2007 6:54 pm

Post by M.Irr »

nobody? :(
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

If you want to avoid global variables (which is a good idea - avoiding it) you can add methods to set some pointers in the event reciever once those objects are created. After all, the EventReceiver is just a class like all others, and you can add as many methods and member variables as you want.
Or you only do the event handling in the receiver, and pass back some values which is handled in your main loop. Depends on how you want to separate game logic and rendering.
M.Irr
Posts: 11
Joined: Thu Dec 20, 2007 6:54 pm

Post by M.Irr »

my idea is a variable who is set to true when the key is pressed but how could i do a variable for all classes?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Static class members use one instance for all objects. But is that really what you want?
M.Irr
Posts: 11
Joined: Thu Dec 20, 2007 6:54 pm

Post by M.Irr »

sorry I am a Beginner an your words are a little bit difficult to understand. I am coding very long with different programms but c is new the biggest problem is that I am German and 14 years so my english is not very good at the moment. Coul you post a little code example how you make things like that :?: Thanks for the fast help!!!! :D
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Just go through one or two tutorials on C++, or even better buy a good book. It will give you not just one single feature, but the full view. That's far better than hoping to get through with just those few things you already new about C++.
For making a class member static simply prefix it with the keyword static. The initialiser for that variable will be only called once in the first object, all other assignments done later on will be reflected as usual.
Post Reply