You need to use at least version 3.6.2 for this

In this lesson, we explain how to show simple and powerful animations. These can make your experiments much nicer. There is also two video tutorials about this lesson on our YouTube channel below.

See it yourself

In this example, a participant needs to press a E for even numbers and an O for odd numbers. If correct, a positive animation is shown (smiley face). If incorrect, a negative animation is shown (shaking head).

This is a very easy task. Make some mistakes to see the effect, because that is all that this lesson is about.

Code explained

Below, you see the experiment source code.

bitmaps
  head1  (1)
  head2
  head3
  smile1 (2)
  smile2
  smile3

table oddeven (3)
  "odd"  1 1
  "even" 2 2
  "odd"  3 1
  "even" 4 2
  "odd"  5 1
  "even" 6 2

task my_task
  keys o e (4)
  show text @2 (5)
  readkey @3 5000 (6)
  clear -1 (7)
  if STATUS == CORRECT (8)
    show text "Correct" 0 100
    show animation 0 0 800 smile1 smile2 smile3 smile2 smile1 (9)
  else
    show text "Wrong" 0 100
    show animation 0 0 1000 head2 head1 head2 head3 head2 head1 head2 head3 head2 head1 head2 (10)
  fi (11)
  delay 1000
  clear -1
  save @1 RT STATUS (11)

block training
  text "Press E for even numbers, O for odd numbers." 0 -100 (12)
  text "Press Space to start task" 0 0
  wait_for_key (13)
  tasklist
    my_task 20 (14)
  end
1 We have three bitmaps for shaking head: head1, head2, and head3
2 We have three bitmaps for smiling head: smile1, smile2, and smile3
3 We have a table for the experiment conditions. This table has three columns, referred to in the task as @1, @2, or @3. Because we have only one table, we do not need to further specify in the task that we use this table
4 We use the keyboard keys O for odd numbers and E for even numbers
5 We show the number. It takes the second column from a randomly chosen row in the table
6 We wait for keyboard response. The correct key is specified in the table.
7 Remove the number after the person has pressed a key
8 If participants pressed correct key, the PsyToolkit STATUS variable is set to CORRECT. If correct, do the next two lines
9 Show the animation at screen center (hence X=0 and Y=0), and the whole animation lasts 800 ms, 200 ms between different animation sequences
10 Show the animation at screen center (hence X=0 and Y=0), and the whole animation lasts 1000 ms, 100 ms between different animation sequences
11 The word "fi" indicates that the if/else block comes to an end
12 In the block, we show two texts with simple instructions
13 wait_for_key in the block waits by default for SPACE key, but you can specify another key if you want
14 Do the task 20 times

Drawing the heads

If you want a cool animation, you do not need anything complex. But there are some basic tips to look at. For example, the heads are not flat, but have a 3D feel to it. This can be easily done in the free drawing software Inkscape.

Watch the tutorial on how I made the images for this specific task.