jamoskullis @ Fri Jun 08, 2007 6:00 pm wrote:
uh im not quite sure how to use ime.elapse can u give me some pointers?
Pointers?
Jokes aside, you can use Time.Elapsed (It finds how much time has passed since program execution) as mentioned. When you first press key record the time. If a person releases and presses the key within a certain time (The first stored time and the new Time.Elapsed) then you can do what needs to be done for your character running.
You can also use cool down instead of time. It simulates time rather then actually using time. Its upto you which method you prefer, but the option is there. (In other words, there is no best method; just preferred methods).
When you first press a movement button, cool down is set to a certain value (like 30, but it could be anything). Each time your main loop runs through, check to see if cool down is greater then 0. If it is, decrease it by one (decrement it). When you release the movement key then make a boolean variable (I will called it 'run', but you can call it anything) true, because your character being able to run is possible. When cool down reaches 0, run becomes false. The next time movement is pressed, check to see if run is true. Viola; its done.
The reason you have the run variable instead of just using the cool down, is because you need something to check to see if you released the movement keys so you can press them again. The cool down is the 'timer' that simulates how long the player has to start running before his next movement will be a walk.
I hope that made sense, good luck.