Frame loops, animation sequences.

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
Peasley
Posts: 3
Joined: Wed Dec 20, 2006 12:44 am

Frame loops, animation sequences.

Post by Peasley »

Ok I'm working on making a fps (just like the rest of us beginners it seems) and I have my gun on the screen. So when I press down on the mouse I would like it to shoot. How would I tell the gun to only play the shooting sequence only once whenever the mouse is pressed?
jimowns
Posts: 62
Joined: Thu Sep 28, 2006 5:28 pm
Location: X-Gamers

Re: Frame loops, animation sequences.

Post by jimowns »

i'm not so far like you .
but can you tell me how did you get our weapon on your screen please .

here you've a code to let you weapon schoot with the left mouse button , i just got it from the examples 15. Demo .

Code: Select all

bool CDemo::OnEvent(SEvent event)
{
	if (!device)
		return false;

	if (event.EventType == EET_KEY_INPUT_EVENT &&
		event.KeyInput.Key == KEY_ESCAPE &&
		event.KeyInput.PressedDown == false)
	{
		// user wants to quit.
		if (currentScene < 3)
			timeForThisScene = 0;
		else
			device->closeDevice();
	}
	else
	if ((event.EventType == EET_KEY_INPUT_EVENT &&
		event.KeyInput.Key == KEY_SPACE &&
		event.KeyInput.PressedDown == false) ||
		(event.EventType == EET_MOUSE_INPUT_EVENT &&
		event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) &&
		currentScene == 3)
	{
		// shoot 
		shoot();
	}
	else
	if (event.EventType == EET_KEY_INPUT_EVENT &&
		event.KeyInput.Key == KEY_F9 &&
		event.KeyInput.PressedDown == false)
	{
		video::IImage* image = device->getVideoDriver()->createScreenShot();
		if (image)
		{
			device->getVideoDriver()->writeImageToFile(image, "screenshot.bmp");
			device->getVideoDriver()->writeImageToFile(image, "screenshot.png");
			device->getVideoDriver()->writeImageToFile(image, "screenshot.tga");
			device->getVideoDriver()->writeImageToFile(image, "screenshot.ppm");
		}
		image->drop();
	}
	else
	if (device->getSceneManager()->getActiveCamera())
	{
		device->getSceneManager()->getActiveCamera()->OnEvent(event);
		return true;
	}

	return false;
}
Peasley
Posts: 3
Joined: Wed Dec 20, 2006 12:44 am

Post by Peasley »

thanks for the help, but I figured it out...all you had to do to have play only once was setLoopMode(false). As for your question on how I got it on the screen here is my code:0

Code: Select all

//load gun model and texture
    scene::IAnimatedMeshSceneNode* gunNode = 0; //define gun node
    scene::IAnimatedMesh* gun = smgr->getMesh("glock.obj");//import gun model

    if(gun){
            
            gunNode = smgr->addAnimatedMeshSceneNode(gun); //add gun model to screen
            camera->addChild(gunNode); //set camera as its parent
            gunNode->setPosition(core::vector3df(0,20,-5)); //move it so it looks like its in the right hand
            gunNode->setRotation(core::vector3df(0,-90,-90)); //set the rotation
            gunNode->setMaterialTexture(0, driver->getTexture("glock.mtl")); //load in the texture (though my gun still seems to stay black)
            
            }
Hope this answers you question
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Post by omar shaaban »

2 noobs helping each other :twisted:
jimowns
Posts: 62
Joined: Thu Sep 28, 2006 5:28 pm
Location: X-Gamers

Post by jimowns »

thanks :)
Post Reply