A simple reaction test to measure your reaction speed. Use OK or EXE to interact, and Shift and left and right arrows in the menu. If you are on Omega or Upsilon, the best results are automatically saved in a file named “rt.sav” Don’t hesitate to tell me if you find any bug by mail: elnix91@gmail.com
from kandinsky import draw_string as txt,fill_rect as rect from time import * from random import randrange as r,randint as ra from ion import keydown as k SKY=(0,0,0) IMP=(0,255,0) TXT=(255,)*3 v=lambda:k(4)|k(52) s=lambda:k(0)|k(3) save="rt.sav" sa=1 try: import os OS=1 except:OS=0 def switch(x,y,on): rect(x,y,23,23,TXT) rect(x+2,y+2,19,19,SKY) if on:rect(x+4,y+4,15,15,IMP) else:rect(x+4,y+4,15,15,(50,50,50)) if OS: if save in os.listdir(): with open(save,"r")as f: A=f.read().split(",") A[0]=int(A[0]) A[1]=int(A[1]) sa=0 if sa:A=[10000,10000] while 1: Hard=0 N=4 while v():1 rect(0,0,320,222,SKY) txt("Press ok to play",80,60,IMP,SKY) txt("Harder:",50,130,TXT,SKY) txt("[Shift]",130,130,(195,50,50),SKY) txt("Number of tests: < >",50,160,TXT,SKY) first=1 while not v(): if s()|first: N=(N-k(0)+k(3))%7 txt(str(N+1),265,160,(255,0,0),SKY) while s():1 if k(12)|first: Hard=not Hard switch(258,130,Hard) while k(12):1 if first:first=0 T=[] N+=1 for i in range(N): rect(0,0,320,222,(255,0,0)) txt("React when green",80,100,TXT,SKY) rect(190,121,50,1,TXT) txt("[OK]",140,150,IMP,SKY) txt(str(i+1)+"/"+str(N),0,0,TXT,(255,0,0)) while v():1 while not v():1 rect(140,150,40,20,(255,0,0)) b=monotonic() t=r(1,10) ok=True while v():1 while monotonic()-b<t: if (ra(0,1000)==0)&((monotonic()-b)<(t-1))&Hard: rect(0,0,320,222,(ra(0,255),0,ra(0,255))) if v(): ok=False T.append(10000) for j in range(25): rect(0,0,320,222,(255,0,0)) txt("TOO SOON!!",110,50,SKY,(255,0,0)) txt("YOU SUCH A FAILURE!",65,70,SKY,(255,0,0)) txt("YOU SHOULD PUT YOUR LIFE",40,90,SKY,(255,0,0)) txt("IN QUESTION!",100,110,SKY,(255,0,0)) txt("YOU AREN'T EVEN ABLE TO",45,130,SKY,(255,0,0)) txt("RECOGNISE COLOR GREEN!",50,150,SKY,(255,0,0)) sleep(0.01) rect(0,0,320,222,SKY) txt("TOO SOON!!",110,50,(255,0,0),SKY) txt("YOU SUCH A FAILURE!",65,70,(255,0,0),SKY) txt("YOU SHOULD PUT YOUR LIFE",40,90,(255,0,0),SKY) txt("IN QUESTION!",100,110,(255,0,0),SKY) txt("YOU AREN'T EVEN ABLE TO",45,130,(255,0,0),SKY) txt("RECOGNISE COLOR GREEN!",50,150,(255,0,0),SKY) # txt("Trop tot!",115,100,(255,0,0),SKY) sleep(0.01) break if ok: rect(0,0,320,222,(0,255,0)) a=monotonic() while not v():1 re=monotonic()-a T.append(round(re*1000)) m=round(sum(T)/N) rect(0,0,320,222,SKY) txt(str(m)+" ms",160-len(str(m))*5-15,110,SKY,(0,255,0)) if N>1: txt("Av. Reaction time:",70,80,IMP,SKY) txt("Times:",135,140,IMP,SKY) txt(" ".join([str(T[i])for i in range(N)]),0,180,(255,0,0),SKY) else: txt("Reaction time:",90,80,IMP,SKY) if (N>1)&(m<A[0]): txt("YOU BEAT BEST AVERAGE!",50,5,(255,255,0),SKY) A[0]=m elif A[0]<10000: txt("Best average:",20,5,(0,255,255),SKY) txt(str(A[0]),160,5,(255,0,0),SKY) if min(T)<A[1]: txt("YOU BEAT BEST SCORE!",60,25,(255,255,0),SKY) A[1]=min(T) elif A[1]<10000: txt("Best score:",20,25,(0,255,255),SKY) txt(str(A[1]),150,25,(255,0,0),SKY) if OS: with open(save,"w")as f: f.write(str(A[0])+","+str(A[1])) while v():1 while not v():1