Sometimes, you want to show a few bitmaps and ask the participant to click on one. Then you want to know which one was clicked and go on.

That is relatively simple to do.

In this example, we have three bitmaps, namely, "prince", "princess", and "frog". In each trial, the participant needs to select one and continue.

Running the code

When you click the experiment link, you will see 3 bitmap images (prince, frog, princess). You need to click one of them and then you will see on the screen a 1, 2, or 3, and later in the datafile you see the reaction time and the number of the bitmap clicked.

This is a very basic example that you can adjust for your own needs.

The PsyToolkit code

# in this task, 3 bitmaps are shown, and participant needs to select one

bitmaps
  prince
  princess
  frog

options
  mouse on

fonts
  arial 20

task click
  draw off
    show bitmap prince  -200 0
    show bitmap frog       0 0
    show bitmap princess 200 0
  draw on
  readmouse l 1 5000
  set $number_of_bitmap bitmap-under-mouse MOUSE_X MOUSE_Y
  show text $number_of_bitmap 200 200
  delay 500
  clear screen
  delay 500
  save RT $number_of_bitmap

block test
  tasklist
    click 3
  end

Code explained bit by bit

Below, the different sections are explained one by one:

draw off
  show bitmap prince  -200 0
  show bitmap frog       0 0
  show bitmap princess 200 0
draw on

The code above shows the 3 bitmaps at the same time. The "draw off" just makes sure that the next three images are shown exactly at the same time when "draw on" is called.

readmouse l 1 5000

The line above expects you to click with the left mouse button one of the bitmaps. The "1" tells PsyToolkit that the expected correct bitmaps is number 1. Actually, you can completely ignore that for this example, because there is no correct bitmap, but PsyToolkit wants a number here. If it is not relevant, just give number 1.

The 5000 is the maximum time to wait (5000 milliseconds = 5 seconds)

set $number_of_bitmap bitmap-under-mouse MOUSE_X MOUSE_Y

The line above sets the variable "number_of_bitmap" to the value of the bitmap currently under the mouse. Note that MOUSE_X and MOUSE_Y refer to the coordinates of where the mouse is currently located on the screen.

Note that the "$" sign tells PsyToolkit that we are using a variable. You can also use a "&" (global variable, one that keeps its value even in new trials).

show text $number_of_bitmap 200 200

Normally, you won’t need the line above, but in this example, we write the the number of the bitmap on screen.

save RT $number_of_bitmap

At the end, we save the reaction time (RT) and the number of the bitmap.