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

Username:   Password: 
 RegisterRegister   
 Double tapping buttons?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Skilgannon




PostPosted: Tue Jan 17, 2006 10:03 pm   Post subject: Double tapping buttons?

Allright, so basically I've been making a side-scroller game sort of program.
Basically you have a ball, and it can bounce around so far, up, up and to the right, and up and to the left. All is well, but I've been wondering... how can I make it so that if you double tap a key a certain procedure happens ?
For example ( I know this is messy coding, I'm a noob ) :

code:
proc up_arrow
    View.Set ("offscreenonly")
    inair := true
    loop
        cls
        height += 1
        comeBack
        drawBall
        delay (5)
        View.Update
        exit when height = 50
    end loop


    loop
        cls
        height -= 1
        comeBack
        drawBall
        delay (5)
        View.Update
        exit when height  = 0
    end loop
    inair:= false
end up_arrow


That is my procedure for jumping straight up into the air.
The comeBack procedure basically makes it so that if the ball is on either edge of the screen, it goes to the other edge ( kind of like how in pacman if you go out the screen on the right you appear on the left ).
The drawBall procedure just draws the ball on the screen.
How would I make it so that turing reads if double tap the key "up" ?

Martin says: Of course you need help. That's why this is the Turing Help forum Wink. No worries. Also - use [code] tags for your code, makes things stay indented. I added them for you.
Sponsor
Sponsor
Sponsor
sponsor
Martin




PostPosted: Tue Jan 17, 2006 10:12 pm   Post subject: (No subject)

To handle double tapping, store the previous keystroke as well as the current one, and the times that they were made at. If previous = current and (current_time - previous_time) < (some small time, like half a second), then a double tap was made.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: