Can anyone tell me whats wrong with it?
Its supposed to move a billboard up or down when you press w or s with a car texture on it.
Code: Select all
#include <irrlicht.h>
#include <iostream>
using namespace std;
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
scene::ISceneNode* node = 0;
IrrlichtDevice* device = 0;
class MyEventReceiver : public IEventReceiver
{
public:
float ypos;
virtual bool OnEvent(SEvent event)
{
if (event.EventType == irr::EET_KEY_INPUT_EVENT&&
!event.KeyInput.PressedDown)
{
switch(event.KeyInput.Key)
{
case KEY_KEY_W:
case KEY_KEY_S:
{
core::vector3df v = node->getPosition();
v.Y += event.KeyInput.Key == KEY_KEY_W ? 2.0f : -2.0f;
node->setPosition(v);
}
return true;
}
}
return false;
}
};
int main()
{
MyEventReceiver receiver;
scene::ISceneManager* smgr = device->getSceneManager();
scene::ISceneNode* car = 0;
device = createDevice(video::DT_OPENGL, core::dimension2d<s32>(640, 480),
16, false, false, &receiver);
device->setWindowCaption(L"Car Game Demo");
video::IVideoDriver* driver = device->getVideoDriver();
node = device->getSceneManager()->addBillboardSceneNode(node, core::dimension2d<f32>(70,93));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, driver->getTexture("data/car.bmp"));
node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();
camera->setPosition(core::vector3df(-50,50,-150));
while(device->run() && driver)
{
if (device->isWindowActive())
{
u32 time = device->getTimer()->getTime();
driver->beginScene(true, true, video::SColor(0,0,150,0));
smgr->drawAll();
driver->endScene();
}
}
device->drop();
return 0;
}