I build driving. The look is promising, and the playerโs perspective is due to the machine that is moving forward. When the car moves forward, its entire environment moves down and scales (now it looks good), which gives the impression that the car is moving forward. Now I want to have some realistic controls for the car to increase speed and then slow down slowly when the up arrow is released. Currently, I call all the move functions for multiple sprites when I press the up arrow. I am looking for a way to control this, so functions are not called so often when the machine is slow, etc. Etc. The code I have so far is:
protected void Drive() { KeyboardState keyState = Keyboard.GetState(); if (keyState.IsKeyDown(Keys.Up)) { MathHelper.Clamp(++TruckSpeed, 0, 100); } else { MathHelper.Clamp(--TruckSpeed, 0, 100); }
I thought this should be easy, but for some reason I cannot understand. It would be very helpful to help here! Thanks
Chris source share