sync on
set display mode 1024, 768, 32
 
global keydown
keydown=1
 
randomize timer()
make_image(1,"Red",rgb(255,0,0))
make_image(2,"Green",rgb(0,255,0))
make_image(3,"Blue",rgb(0,0,255))
set text size 24
 
dim rps(3)
rps(1)=1
rps(2)=2
rps(3)=3
 
 
cls
center text 512, 300, "Instructions:  You have 15 seconds to match as many colors as possible."
center text 512, 350, "The top box shows the current color to match.  The bottom boxes remind you of your keys."
center text 512, 400, "Keys:  Red=Left Arrow, Green=Down Arrow, Blue=Right Arrow."
center text 512, 450, "Hitting the correct key adds a point.  Hitting an incorrect key subtacts a point."
center text 512, 500, "press any key to begin."
sync
sync
wait key
 
t=timer()
tt=t+15000
 
repeat
 
  cls
  sync
  wait 50
  t=timer()
  text 5,5, "score:  "+ str$(score)
  text 800,5, "time left: " + str$((tt-t)/1000)
  sync
`  wait 200
  a=rnd(2)+1
  paste image a, 362,20
 
 
  paste image 1, 30, 450
  paste image 2, 362, 450
  paste image 3, 694, 450
 
 
  sync
  k=get_input()
  if k=rps(a) then inc score else dec score
until t>tt
 
cls
 
center text 512, 324, "Time up!"
center text 512, 384, "Final Score:  " +str$(score)
center text 512, 444, "Press escape to exit"
 
 
sync
do
loop
 
 
Function make_image(num as integer, t$ as string, col as dword )
  ink col, 0
  box 0,0,300,300
  ink rgb(255,255,255), 0
  set text size 48
  set text font "arial"
  text 150- (text width(t$)/2), 150- (text height(t$)/2), t$
  get image num, 0,0,300,300,1
endfunction
 
function get_input()
  if keydown=1
  repeat
    s=scancode()
  until s=0
  endif
 
  repeat
    s=scancode()
  until s<>0
  keydown=1
 
 
  if s=203 then s=1 `left key.  Rock
  if s=208 then s=2 `up key.  Paper
  if s=205 then s=3 `right key. Scissors
 
endfunction s