Hooray for keystates!
August 30th, 2009 6:15 amShows how much of a noob I am really, but I just discovered that SDL lets you check keystates at any time, not just when a keypress event is raised. This makes the movement code much, much simpler. Currently attempting to let you jump, which currently conflicts horribly with the code that stops you falling through the floor… Wait a minute! I think I’ve cracked it! I just need to do a check if the vertical velocity is negative! Yay!
Tags: SDL
I mentioned this elsewhere already, but you might get some use out of StickyInput:
http://code.bluedinosaurs.com/SDL.html
Cool, thanks.
I might stick that in later if I get time.
If you just check for negative velocity you’ll be able to keep jumping as long as you’re moving upwards XD
Yeah, it checks for solid ground before jumping. It’s just that I have a second piece of code which was basically
If there is no square beneath you, fall
Else, snap to the ground.
Which stopped you being able to leave the ground. Using a grid system with a smooth-movement system is complicated. *_*