Tiroteio com irrlicht
660 palavras
3 páginas
#include #include
#include "tools.h"
using namespace irr;
using namespace core; using namespace scene; using namespace video; using namespace io; using namespace gui;
struct camera
{
vector3df posicao; vector3df target; vector3df rotacao;
};
void trocaCamera(ICameraSceneNode * cam, camera tipo)
{
cam->setPosition(tipo.posicao); cam->setTarget(tipo.target);
};
int main()
{
MyEventReceiver receiver; IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2d(1300, 700), 32, false, false, false, &receiver);
IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); IGUIEnvironment* guienv = device->getGUIEnvironment();
camera cam1; cam1.posicao = vector3df(0,1,-1); cam1.target = vector3df(0,0,5);
camera cam2; cam2.posicao = vector3df(0,0.0,-0.3); cam2.target = vector3df(0,0,0);
IMeshSceneNode * metralha = smgr->addMeshSceneNode(smgr->getMesh("metralha.x")); metralha->setMaterialFlag(EMF_LIGHTING, false);
IMeshSceneNode * aviao = smgr->addMeshSceneNode(smgr->getMesh("aviao.x")); aviao->setMaterialFlag(EMF_LIGHTING, false);
ITexture * mira = driver->getTexture("aim.png"); driver->makeColorKeyTexture(mira, position2d(78,78));
metralha -> getMaterial(0).MaterialType = EMT_TRANSPARENT_ALPHA_CHANNEL_REF; metralha-> getMaterial(0).BackfaceCulling = false; metralha-> getMaterial(0).TextureLayer[0].LODBias = 128; metralha-> getMaterial(0).TextureLayer[0].Texture = mira;
IMeshSceneNode * explosao = smgr->addMeshSceneNode(smgr->getMesh("fogo.x")); explosao->setMaterialFlag(EMF_LIGHTING, false); explosao->setMaterialTexture(0, driver->getTexture("gun_fire.png")); explosao->setParent(aviao); explosao->setVisible(false);
ITriangleSelector * seletor = smgr->createTriangleSelector(aviao->getMesh() ,aviao);