Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 is double clicking arrow keys possible?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jamoskullis




PostPosted: Thu Jun 07, 2007 8:53 pm   Post subject: is double clicking arrow keys possible?

for my game i want my character to walk when i press an arrow key once and hold it. when i double press an arrow key i want him to run like in the dragon ball games. is this possible with turing?
Sponsor
Sponsor
Sponsor
sponsor
CodeMonkey2000




PostPosted: Thu Jun 07, 2007 9:09 pm   Post subject: RE:is double clicking arrow keys possible?

Yes, but you'll need to play around with Time.Elapsed. If the time interval between subsequent arrow presses is less than or equal to, run.
jamoskullis




PostPosted: Fri Jun 08, 2007 6:00 pm   Post subject: Re: is double clicking arrow keys possible?

uh im not quite sure how to use ime.elapse can u give me some pointers?
Jerrik




PostPosted: Sun Jun 10, 2007 12:37 am   Post subject: Re: is double clicking arrow keys possible?

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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: