Results 1 to 3 of 3

Thread: Reaction speed tester

  1. #1
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default Reaction speed tester

    I don't consider this a script but here is a neato little reaction speed tester made with simba:




    Move your mouse to the squares, it will test the amount of time it takes between each time you hover over a rectangle! The background color and shape color/size change each time to mix it up!

    The score is kind of pointless, I just added it for fun. The smaller the rectangle the more points you get!

    Example results:
    Code:
    ***************Results***************
    Score: 92306
    Sample size: 15
    Average points per square: 6154
    Average reaction time: 710 ms
    *************************************

    code:

    Simba Code:
    {$I SRL/SRL.Simba}
    Var
      GameForm:TForm;
      sq:Tshape;
      IntialSpawn, squarepresent:Boolean;
      score:extended;
      t, g, hits, reply:integer;
      samplesize:string;

    Procedure EndGame;
    begin
      Cleardebug;
      if (hits>=StrToInt(samplesize)) then
      begin
        writeln('***************Results***************');
        writeln('Score: ' + ToStr(Round(score)));
        writeln('Sample size: ' + samplesize);
        Writeln('Average points per square: ' + ToStr(Round(score/(StrToInt(samplesize)))));
        Writeln('Average reaction time: ' + ToStr(G/(StrToInt(samplesize))) + ' ms');
        writeln('*************************************');
      end else if (hits<StrToInt(samplesize)) then writeln('You did not test enough!');
    end;

    procedure NewEvent(Sender: TObject; Shift: TShiftState; x, y: Integer);
    begin
      if (hits>=StrToInt(samplesize)) then GameForm.CLOSE;
      GameForm.color := random(16777215);
      g := g + TimeFromMark(t);
      Score := Score + (40000/sq.width) + (40000/sq.Height) + (500000/TimeFromMark(t));
      hits := hits+1;
      sq.Width := random(35) + 5;
      sq.Height := random(35) + 5;
      sq.left := random(500);
      sq.top := Random(500);
      sq.PEN.color := random(16777215);
      sq.BRUSH.color := random(16777215);
      sq.ONMOUSEMOVE := @NewEvent;
      MarkTime(t);
    end;

    Procedure CreateSquare(Sender:Tobject);
    begin
      if not (IntialSpawn) then
      begin
        IntialSpawn := true;
        sq := tShape.Create(GameForm);
        sq.parent := GameForm;
        sq.Visible := true;
        sq.Width := random(40) + 10;
        sq.Height := random(40) + 10;
        sq.left := random(GameForm.Width-15);
        sq.top := Random(GameForm.Height-15);
        sq.PEN.color := random(16777215);
        sq.BRUSH.color := random(16777215);
        sq.ONMOUSEMOVE := @NewEvent;
        MarkTime(t);
      end;
    end;

    procedure InitForm;
    begin
      GameForm := TForm.Create(nil);
      GameForm.caption := 'Reaction speed tester';
      GameForm.color := random(16777215);
      GameForm.Left := 250;
      GameForm.top := 250;
      GameForm.Width := 600;
      GameForm.Height := 500;
      GameForm.OnClick := @CreateSquare;
    end;

    procedure SafeInitForm;
    var
      v: TVariantArray;
    begin
      SetLength(V, 0);
      ThreadSafeCall('InitForm', v);
    end;

    procedure ShowFormModal;
    begin
      try
        GameForm.ShowModal;
      except
        writeln('ERROR WITH THE FORM');
      end;
    end;

    procedure SafeShowFormModal;
    var
      v: TVariantArray;
    begin
      SetLength(V, 0);
      ThreadSafeCall('ShowFormModal', v);
    end;
    begin
      inputquery('Sample size','How many times would you like your reaction to be tested?', samplesize);
      reply := messagebox('Move your mouse to the rectangles as fast as you can! Click the form to begin the test.','Information',1);
      if (reply=2) then Terminatescript;
      SafeInitForm;
      SafeShowFormModal;
      EndGame;
    end.

  2. #2
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Did this a few times and it crashed my Simba. So the higher the score the better or....?

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  3. #3
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Flight View Post
    Did this a few times and it crashed my Simba. So the higher the score the better or....?
    The higher the reaction time and points per square, points per square is based off reaction time and how big the square is

    My simba crashed once I'm not sure what it is

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •