I am in the process of making an Ogre based Lunar Lander style game.
Everything works fine except when I press the 'Up arrow' the object immediately accelerates upwards as opposed to the desired downward deceleration of the object (eventually having it go back up again).
If anyone could help out as to why this is happening, it would be great. I have spent a few days on this and am starting to tear my hair out
if(KEY_DOWN(VK_UP)&&GetFocus()==(graphics->getWindowHandle()))
{
if(bKeyHeld==false)
{
StartCounter();
u=v;
}
s1=(0.5*(a1*(t*t)));
v1=u*u+2*a1*s1;
v1=sqrt(v1);
bKeyHeld=true;
}
if(KEY_UP(VK_UP)&&GetFocus()==(graphics->getWindowHandle())&&bKeyHeld==true)
{
bKeyHeld=false;
StartCounter();
u=v;
}
t=GetCounter()/1000;
s=(0.5*(a*(t*t)));
v=u*u+2*a*s;
v=sqrt(v);
if(a<0)
v=-v;
vt=v+v1;
graphics->assetTranslate(1,Vector3(0,vt/3000,0));
The equations used are from basic physics.