PDA

View Full Version : Jumping?



LangdonAlgers
01-20-2006, 12:16 PM
I'm currently making a bare-bones 2D platform game like Mario (only much simpler). My first non-trivial OpenGL program.

And I've hit a wall. What I have so far is a box (the character), and in the myTimer function that GlutTimerFunc uses I have boxX += speedX, and the same with boxY. Then in the keyboard function I have various keys changing the speed. Not really complicated, so I hope I have made myself clear enough.

My problem is the jumping. Since the keyboard function only changes the speed to a single value, I don't know of a way to implement the 'e' key for example to change the speed to 2, then after a few milliseconds to 1, then 0, then -1, and at last -2, to land again. Sure, if I assign each of these speeds to a button and press them all in succession I get what I want, but that's obviously not an acceptable solution. But it tells me that there must be a pretty simple way of doing this that I'm not finding.