Double tapping buttons?
Author |
Message |
Skilgannon
|
Posted: 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 . No worries. Also - use [code] tags for your code, makes things stay indented. I added them for you. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Martin
|
Posted: 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. |
|
|
|
|
|
|
|