Something (which may or may not be good) that I've resorted to doing
is, because of consistent-speed versus inconsistent framerate, I have
-- assuming only left/right up/down movement, and that they are
opposed in those pairs -- two signed integer variables that I use
for movement. This setup is for a top-down four-directional-scroller
style, but could be adapted to other styles. Anyway, when the user
presses left, I subtract 1 from the forwardMovement variable, righ I
add 1. Up I add one to the upwardMovement variable, and down I
subtract 1. Then you do the reverse when each key is released.
This gives me two nice equations for moving the character:
--Scott
On Oct 17, 2006, at 12:25 PM, Stephen Smith wrote:
Here's a slight tweak to that: instead of creating a new var for each key, what I do is create a boolean array, and then on a KeyDown event (I use Java so whatever the C equivalent is) just set the cell of the ascii code to true (and false when the key is released).
Steve
Alan Wolfe wrote:Oh here's another concept which greatly helps in game programming...
Instead of checking for keyboard events (such as making the player move when the player presses an arrow key), what you want to do is store the STATES of keys - whether they are pressed down or not.
for example, when the user presses the right arrow key, instead of moving the player, just set RightArrowKeyPressed=1, and when they let go of the key, set RightArrowKeyPressed=0.
Then, in your UpdateWorld function, all you do is...
if(RightArrowKeyPressed==1)
//move player right
if(LeftArrowKeyPressed==1)
//move player left
if(SpaceBarPressed==1)
//shoot a bullet
when you do it this way, it makes for much smoother controls, and lets you do things like move diagonally and shoot at the same time - as well as holding in the fire button to do rapid fire.
On 10/16/06, *David Cornell* <kaosboy192000@xxxxxxxxx <mailto:kaosboy192000@xxxxxxxxx>> wrote:
I want to create a Flash MX game in the side-scrolling beat-em-up
fashion, hopefully 3/4 perspective, but I have NO IDEA how to
start aside from sketching character models, scanning them in, and
editing variations with a good art editor. Beyond that, I could
use a technical starting point for this project.
--------------------- To unsubscribe go to http://gameprogrammer.com/mailinglist.html
--------------------- To unsubscribe go to http://gameprogrammer.com/mailinglist.html