hi,
Im trying to make a ship move, and i need it to move smoothly, but now it move one bit at a time and looks really silly and bad, like a jerking motion. also how can i make it so i can press more than one key at a time so that the ship can move diagnally rather than just left then up etc..
my code is as follows:
class MyEventReceiver : public IEventReceiver
{
public:
//============================================CONTROLS================================================
virtual bool OnEvent(SEvent event)
{
if (event.KeyInput.Key == KEY_KEY_A)
{
core::vector3df v = Munch->getPosition();
v.X += -2.0f;
Munch->setPosition(v);
}
return true;
}
};
//=============================================CONTROLS END=============================================
Any help would be appreciated
regards
Keyboard Input - Smooth And Multiple keypress
Keyboard Input - Smooth And Multiple keypress
The idea of war is not to die for your country, but to make the other bastard die for his!
Search for bool keys, or click one of the links below...
The gist of it is that you just capture the key states in the event receiver. When a key is pressed down you set a flag, and when it is released, you clear the flag. Then, in the game loop, you check the state of the keys and do something based on their status.
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=25813
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=17033
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=19657
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=25517
Travis
The gist of it is that you just capture the key states in the event receiver. When a key is pressed down you set a flag, and when it is released, you clear the flag. Then, in the game loop, you check the state of the keys and do something based on their status.
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=25813
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=17033
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=19657
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=25517
Travis
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
If you download the latest SVN version, example 04.Movement has been updated to demonstrate storing key states.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way