Computer Science Canada

Turing Timer For Games

Author:  odd toddd [ Fri May 22, 2020 3:15 am ]
Post subject:  Turing Timer For Games

% variables
var last1, now1 : int
var last2, now2 : int
var timer1 : int := 0
var timer2 : int := 0
var timer1set, timer2set : int := 0
var total : int := 1
var continue : string (1)
var input1 : string
var input2 : string


% start
put "Program Times Each Input and Adds the Total Time"
put "Press any Key to Start"
getch (continue)
cls


% timer 1
last1 := Time.Elapsed
process timer_1
loop
now1 := Time.Elapsed
if (now1 - last1 >= 1000) then
timer1 := timer1 + 1
last1 := now1
end if
end loop
end timer_1
fork timer_1


% question 1
loop
put "QUICK TYPE 'faster'"
get input1
exit when input1 = "faster"
put "Try Again"
delay (1500)
end loop
put timer1, " Seconds"
timer1set := timer1
getch (continue)
cls


% timer 2
last2 := Time.Elapsed
process timer_2
loop
now2 := Time.Elapsed
if (now2 - last2 >= 1000) then
timer2 := timer2 + 1
last2 := now2
end if
end loop
end timer_2
fork timer_2


% question 2
loop
put "QUICK TYPE 'slower'"
get input2
exit when input2 = "slower"
put "Try Again"
delay (1500)
end loop
put timer2, " Seconds"
timer2set := timer2
getch (continue)
cls


% timer total
total := timer1set + timer2set
put "Total Seconds ", total


: