I have come to a complete brick wall in my mind. I am trying to write a
game where the user has to hit the space bar as close to a sound that
plays every second. If the user hits the space bar and releases it
before the sound, one set of boxes will light up.
If the user hits and releases the space bar after the sound, another set
of boxes will light up.
I have some code but am blanking on how to move forward.
Need some guidance from better programmers then I.
Thanks in advance.
Joe
Code sample:
def ag_start
total = 5
c = 0
sound_timer = Timer.every(1000)
{Sound.play(“c:\windows\media\chimes.wav”)}
while c < total
####listen for half a second for if user presses the space bar before
the sound
evt_key_up() { | event | if event.get_key_code == 32 then #get the
time difference from the key up to the sound
}
#play sound ########################
evt_key_up() { | event | if event.get_key_code == 32 then #get the
time difference from the sound to the key up
}
#listen for half a second for if the user presses the space bar after
the sound
#repeat for time required
c = c + 1
end
#sound_timer.stop
end