I'm trying to code a control for the camera (with WSAD). That actually looks so:
Code: Select all
class MyEventReceiver : public IEventReceiver{public: virtual bool OnEvent(SEvent event)
{
core::vector3df cPos = camera->getPosition();
// Falls ESC gedrückt, Programm beenden
if(event.EventType == EET_KEY_INPUT_EVENT &&
event.KeyInput.Key == KEY_ESCAPE &&
event.KeyInput.PressedDown == false)
device->closeDevice();
if(event.KeyInput.Key == KEY_KEY_W)
{
cPos.Z+=7.5;
camera->setPosition(cPos);
}
if (event.KeyInput.Key == KEY_KEY_S)
{
cPos.Z-=7.5;
camera->setPosition(cPos);
}
if (event.KeyInput.Key == KEY_KEY_A)
{
cPos.X-=7.5;
camera->setPosition(cPos);
}
if (event.KeyInput.Key == KEY_KEY_D)
{
cPos.X+=7.5;
camera->setPosition(cPos);
}
if (event.KeyInput.Key == KEY_SPACE)
{
cPos.Y+=20;
camera->setPosition(cPos);
}
else
{
if(camera)
return camera->OnEvent(event);
return false;
}}
};
And one more : When i press one of the keys, the camera moves one time the given value and then stops for maybe half a second after its moving normally (like known from a normal fps...). What's the reason for that ?