Code: Select all
Bullet(scene::ISceneManager* smgr, video::IVideoDriver* driver, core::vector3df playerLoc, core::vector3df playerRot)
{
moverate = 5;
life = 200;
node = smgr->addLightSceneNode(0, playerLoc, video::SColorf(1.0f, 0.6f, 0.7f, 1.0f), 600.0f);
//node->setParent(node);
//scene::ISceneNodeAnimator* anim = 0;
//anim = smgr->createFlyCircleAnimator (core::vector3df(0,150,0),250.0f);
//node->addAnimator(anim);
//anim->drop();
// attach billboard to light
node = smgr->addBillboardSceneNode(node, core::dimension2d<f32>(25, 25));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
node->setMaterialTexture(0, driver->getTexture("../media/textures/bullet.bmp"));
movement.Y = (cos(deg2rad(playerRot.X))* moverate);
movement.Z = (sin(deg2rad(playerRot.X))* moverate);
}
virtual bool Move(MyEventReceiver receiver)
{
life--;
core::vector3df v = node->getPosition();
v.Y += movement.Y;
v.Z += movement.Z;
if (abs(v.Y) > 150)
v.Y > 150 ? v.Y = -150 : v.Y = 150;
if (abs(v.Z) > 200)
v.Z > 200 ? v.Z = -200 : v.Z = 200;
node->setPosition(v);
if(life == 0)
{
node->remove();
delete this;
return false;
}
else
return true;
}
My second questionis if i am removing these bullet objects the correct way. if you notice, they have a life of 200 frames. then I get rid of them. However, I don't have any limits yet as to how many i can fire. So goofing around I shoot a whole bunch and it drops the frame rate a lot if i shoot enough. But i would expect the framerate to come back up after all the bullets cleared themselves up, but it stays low. So I'm wondering if I'm getting rid of them correctly.