OGRE (Object-Oriented Graphics Rendering Engine)

Changing the way the ship moves

We want to change the way the ship moves for now so that we can rotate it. This will mean that when we are working on the lights on the wings we can get a better look at them.

Open Ship.h and change the frameStarted method to be

        bool frameStarted(const FrameEvent& evt)
        {
    		// Move upto 80 units/second
    		Real MoveFactor = 80.0 * evt.timeSinceLastFrame;

    		// Copy the current state of the input devices
    		mInputDevice->capture();

    		// Move the ship node!
    		if(mInputDevice->isKeyDown(Ogre::KC_UP))
    		  mShipNode->translate(0.0, MoveFactor, 0.0);

    		if(mInputDevice->isKeyDown(Ogre::KC_DOWN))
    		  mShipNode->translate(0.0, -MoveFactor, 0.0);

    		// Instead of moving the ship left and right, rotate it using yaw()
    		if(mInputDevice->isKeyDown(Ogre::KC_LEFT))
    		  mShipNode->yaw(MoveFactor);

    		if(mInputDevice->isKeyDown(Ogre::KC_RIGHT))
    		  mShipNode->yaw(-MoveFactor);

    		return true;
        }

Back to Index |  | << Previous section | Next section >>