Hey, I know this is an odd question, but I have asked on other forums and haven't gotten much of a response. The game I am working on is actually in XNA, but seeing that the game I am wondering about is written in Java I was hoping someone might be able to help out a bit. I am trying to make a game that has a similar flying mechanic to (
http://www.terabytelabs.net/shyguys-cave-of-death/#comments). My problem is that when I release the spacebar the ship will continue to climb up for a bit before starting to descend....and overall it doesn't seem to be nearly as snappy as the shyguy game.
If it would be any help here is my current code...again in C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| if (currentState.IsKeyDown(Keys.Space) == true) {
sPos.Y += .4f; velocity = 2;
}
if (currentState.IsKeyDown(Keys.Space) == false) { sPos.Y -= .8f; velocity = -1; }
}
public void Update(GameTime theGameTime) { KeyboardState aCurrentKeyboardState = Keyboard.GetState();
spritePosition.X = spritePosition.X + 5; velocity -= acceleration * (float)theGameTime.ElapsedGameTime.TotalSeconds;
sPos.Y -= velocity * (float)theGameTime.ElapsedGameTime.TotalSeconds;
spritePosition.Y -= sPos.Y;
Movement(aCurrentKeyboardState);
} |
Obviously I don't expect to get a response written in C#...just a general idea about what I might be doing wrong.
Thanks for the help,
Troy