Millisecond Forums

Help with animation

https://forums.millisecond.com/Topic35600.aspx

By sbashyam - 8/15/2023

Hi,
I have attached the code of the study below. We currently have it programmed as a drag and drop task (participants are required to drag some ducks into a pond). I am trying to animate the stimuli in such a way, that participants just have to click on the ducks and they move into the pond on their own. I did try the animation attribute but was hoping I could get some help on the coding! 
Link to the stimuli folder - https://drive.google.com/drive/folders/1x08A2f3kyQxJfbDic-MFXZaCDMivUaZT?usp=share_link
By Dave - 8/15/2023

sbashyam - 8/15/2023
Hi,
I have attached the code of the study below. We currently have it programmed as a drag and drop task (participants are required to drag some ducks into a pond). I am trying to animate the stimuli in such a way, that participants just have to click on the ducks and they move into the pond on their own. I did try the animation attribute but was hoping I could get some help on the coding! 
Link to the stimuli folder - https://drive.google.com/drive/folders/1x08A2f3kyQxJfbDic-MFXZaCDMivUaZT?usp=share_link

What precisely are your questions?
By sbashyam - 8/15/2023

Hi Dave, could you show me a way to animate in such a way that once someone clicks on a duck, it goes into the pond as opposed to the drag and drop method that the experiment currently has?
By Dave - 8/15/2023

sbashyam - 8/15/2023
Hi Dave, could you show me a way to animate in such a way that once someone clicks on a duck, it goes into the pond as opposed to the drag and drop method that the experiment currently has?

This requires a vastly different setup than the current drag & drop approach, so you'll have to rewrite large parts of it.

Study e.g. https://www.millisecond.com/download/library/v6/cyberball/cyberball5/cyberball5.web , where you click on a player and a ball then is animated to be thrown to that player. Essentially the same thing as what you need to do. Click a duck, then that duck gets moved from wherever it currently is to the pond.
By Dave - 8/15/2023

Dave - 8/15/2023
sbashyam - 8/15/2023
Hi Dave, could you show me a way to animate in such a way that once someone clicks on a duck, it goes into the pond as opposed to the drag and drop method that the experiment currently has?

This requires a vastly different setup than the current drag & drop approach, so you'll have to rewrite large parts of it.

Study e.g. https://www.millisecond.com/download/library/v6/cyberball/cyberball5/cyberball5.web , where you click on a player and a ball then is animated to be thrown to that player. Essentially the same thing as what you need to do. Click a duck, then that duck gets moved from wherever it currently is to the pond.

Here's a rewrite of the script along those lines. Work through this until you understand what it does and how it works. The comments are there as signposts. Implementing the demo round is left as an exercise.

<data>
/ columns = [date, time, subject, group, blockcode, trialcode, response, correct, latency, stimulusitem,
values.target_n, values.n_dropped, values.ducks_dropped,
expressions.stop1, expressions.stop2, expressions.stop3, expressions.stop4, expressions.stop5, expressions.stop6,
trial.one_end.totalcount, trial.one_end.totalcorrectcount, trial.one_end.totalerrorcount,
trial.two_end.totalcount, trial.two_end.totalcorrectcount, trial.two_end.totalerrorcount,
trial.three_end.totalcount, trial.three_end.totalcorrectcount, trial.three_end.totalerrorcount,
trial.four_end.totalcount, trial.four_end.totalcorrectcount, trial.four_end.totalerrorcount,
trial.five_end.totalcount, trial.five_end.totalcorrectcount, trial.five_end.totalerrorcount,
trial.six_end.totalcount, trial.six_end.totalcorrectcount, trial.six_end.totalerrorcount
]
/ separatefiles = true
</data>

<defaults>
/ inputdevice = mouse
/ fontstyle = ("Verdana", -13, false, false, false, false, 5, 0)
</defaults>

<expressions>
/ stop1 = if (trial.one_end.totalerrorcount >=2) true else false
/ stop2 = if (trial.one_end.totalcorrectcount >=2 && trial.two_end.totalerrorcount >=2) true else false
/ stop3 = if (trial.two_end.totalcorrectcount >=2 && trial.three_end.totalerrorcount >=2) true else false
/ stop4 = if (trial.three_end.totalcorrectcount >=2 && trial.four_end.totalerrorcount >=2) true else false
/ stop5 = if (trial.five_end.totalcorrectcount >=2 && trial.six_end.totalerrorcount >=2) true else false
/ stop6 = if (trial.six_end.totalcorrectcount >=2) true else false
</expressions>

// global variables
<values>
/ target_n = 0 // how many ducks to move to the pond
/ n_dropped = 0 // running count of ducks moved
/ ducks_dropped = "" // string holding the names of all objects (ducks) moved
/ duck_index = 0 // which one of the 10 ducks was selected in the given trial
/ level = "" // current level
/ labelitem = 0 // what label to display given the current level
/ duck_1_a_x = 0% // x position of the 1st duck
/ duck_1_a_y = 0% // y position of the 1st duck
/ duck_1_b_x = 0% // ...
/ duck_1_b_y = 0%
/ duck_2_a_x = 0%
/ duck_2_a_y = 0%
/ duck_2_b_x = 0%
/ duck_2_b_y = 0%
/ duck_3_a_x = 0%
/ duck_3_a_y = 0%
/ duck_3_b_x = 0%
/ duck_3_b_y = 0%
/ duck_4_a_x = 0%
/ duck_4_a_y = 0%
/ duck_4_b_x = 0%
/ duck_4_b_y = 0%
/ duck_5_a_x = 0%
/ duck_5_a_y = 0% //...
/ duck_5_b_x = 0% // x position of the 10th duck
/ duck_5_b_y = 0% // y postiion of the 10th duck
/ pond_x = 75% // x position of the pond
/ pond_y = 50% // y position of the pond
/ anim_item = 0 // which duck (left vs right facing) to display during the animation
/ anim_start_x = 0% // start x position of the animation (depends on which duck was selected to be moved)
/ anim_start_y = 0% // start y position of the animation
/ anim_end_x = 0% // end x position of the animation (somewhere in the pond area)
/ anim_end_y = 0% // end y position of the animation
</values>

// array holding level names
<list level>
/ items = ("one", "two", "three", "four", "five", "six")
</list>

// array holding end trial for each level
<list level_endtrial>
/ items = (trial.one_end, trial.two_end, trial.three_end, trial.four_end, trial.five_end, trial.six_end)
</list>

// array holding the duck object names
<list ducks_object>
/ items = ("duck_1_a", "duck_1_b", "duck_2_a", "duck_2_b", "duck_3_a", "duck_3_b", "duck_4_a", "duck_4_b", "duck_5_a", "duck_5_b")
</list>

// array holding x positions for the 10 ducks (left to right from duck_1_a to duck_5_b)
<list ducks_x>
/ items = (24%, 5%, 20%, 15%, 25%, 5%, 10%, 20%, 30%, 13%)
</list>

// array holding y positions for the 10 ducks (left to right from duck_1_a to duck_5_b)
<list ducks_y>
/ items = (45%, 30%, 30%, 40%, 55%, 20%, 35%, 35%, 55%, 15%)
</list>

// array holding x positions for the 10 ducks (left to right from duck_1_a to duck_5_b)
<list ducks_item>
/ items = (1, 2, 1, 2, 1, 2, 1, 2, 1, 2)
</list>

// array indicating whether the given static duck object should be skipped during the animation trial
<list ducks_skip>
/ items = (false, false, false, false, false, false, false, false, false, false)
</list>

// holds responses given in the current task round
<list responses>
</list>

<expt main>
/blocks = [1=test; 2=end]
</expt>

<block test>
/ stop = [
    expressions.stop1 || expressions.stop2 || expressions.stop3 || expressions.stop4 || expressions.stop5 || expressions.stop6
]
/ trials = [1=one]
</block>

<block end>
/trials = [1=end]
</block>

<trial end>
/ stimulusframes = [1=clearscreen, thank_you]
/ validresponse = (lbuttondown)
</trial>

<trial one>
/ ontrialbegin = [
    values.level = "one"; // set the level name
    values.target_n = 1; // set target N for the level
    values.labelitem = 2; // set the correct onscreen instruction item to display
    // reset variables and lists for this round
    values.n_dropped = 0; // no ducks dropped yet
    values.ducks_dropped = ""; // same
    list.responses.reset(); // reset list holding response
    list.ducks_x.reset(); // rest to duck x & y positions
    list.ducks_y.reset();
    list.ducks_skip.reset(); // we display all objects
    
    // set the position variables
    values.duck_1_a_x = list.ducks_x.item(1);
    values.duck_1_a_y = list.ducks_y.item(1);
    values.duck_1_b_x = list.ducks_x.item(2);
    values.duck_1_b_y = list.ducks_y.item(2);
    values.duck_2_a_x = list.ducks_x.item(3);
    values.duck_2_a_y = list.ducks_y.item(3);
    values.duck_2_b_x = list.ducks_x.item(4);
    values.duck_2_b_y = list.ducks_y.item(4);
    values.duck_3_a_x = list.ducks_x.item(5);
    values.duck_3_a_y = list.ducks_y.item(5);
    values.duck_3_b_x = list.ducks_x.item(6);
    values.duck_3_b_y = list.ducks_y.item(6);
    values.duck_4_a_x = list.ducks_x.item(7);
    values.duck_4_a_y = list.ducks_y.item(7);
    values.duck_4_b_x = list.ducks_x.item(8);
    values.duck_4_b_y = list.ducks_y.item(8);
    values.duck_5_a_x = list.ducks_x.item(9);
    values.duck_5_a_y = list.ducks_y.item(9);
    values.duck_5_b_x = list.ducks_x.item(10);
    values.duck_5_b_y = list.ducks_y.item(10);
]
/ stimulusframes = [1=clearscreen]
/ validresponse = (0)
/ trialduration = 1000 // 1 second pre-round blank
/ branch = [
    // go to duck selection trial
    return trial.selectduck;
]
/ recorddata = false
</trial>

// same as above, for level two
<trial two>
/ ontrialbegin = [
    values.level = "two";
    values.target_n = 2;
    values.labelitem = 3;
    values.n_dropped = 0;
    values.ducks_dropped = "";
    
    list.responses.reset();
    list.ducks_x.reset();
    list.ducks_y.reset();
    list.ducks_skip.reset();
    values.duck_1_a_x = list.ducks_x.item(1);
    values.duck_1_a_y = list.ducks_y.item(1);
    values.duck_1_b_x = list.ducks_x.item(2);
    values.duck_1_b_y = list.ducks_y.item(2);
    values.duck_2_a_x = list.ducks_x.item(3);
    values.duck_2_a_y = list.ducks_y.item(3);
    values.duck_2_b_x = list.ducks_x.item(4);
    values.duck_2_b_y = list.ducks_y.item(4);
    values.duck_3_a_x = list.ducks_x.item(5);
    values.duck_3_a_y = list.ducks_y.item(5);
    values.duck_3_b_x = list.ducks_x.item(6);
    values.duck_3_b_y = list.ducks_y.item(6);
    values.duck_4_a_x = list.ducks_x.item(7);
    values.duck_4_a_y = list.ducks_y.item(7);
    values.duck_4_b_x = list.ducks_x.item(8);
    values.duck_4_b_y = list.ducks_y.item(8);
    values.duck_5_a_x = list.ducks_x.item(9);
    values.duck_5_a_y = list.ducks_y.item(9);
    values.duck_5_b_x = list.ducks_x.item(10);
    values.duck_5_b_y = list.ducks_y.item(10);
]
/ stimulusframes = [1=clearscreen]
/ validresponse = (0)
/ trialduration = 1000
/ branch = [
    return trial.selectduck;
]
/ recorddata = false
</trial>

// same as above, for level three
<trial three>
/ ontrialbegin = [
    values.level = "three";
    values.target_n = 3;
    values.labelitem = 4;
    values.n_dropped = 0;
    values.ducks_dropped = "";
    
    list.responses.reset();
    list.ducks_x.reset();
    list.ducks_y.reset();
    list.ducks_skip.reset();
    values.duck_1_a_x = list.ducks_x.item(1);
    values.duck_1_a_y = list.ducks_y.item(1);
    values.duck_1_b_x = list.ducks_x.item(2);
    values.duck_1_b_y = list.ducks_y.item(2);
    values.duck_2_a_x = list.ducks_x.item(3);
    values.duck_2_a_y = list.ducks_y.item(3);
    values.duck_2_b_x = list.ducks_x.item(4);
    values.duck_2_b_y = list.ducks_y.item(4);
    values.duck_3_a_x = list.ducks_x.item(5);
    values.duck_3_a_y = list.ducks_y.item(5);
    values.duck_3_b_x = list.ducks_x.item(6);
    values.duck_3_b_y = list.ducks_y.item(6);
    values.duck_4_a_x = list.ducks_x.item(7);
    values.duck_4_a_y = list.ducks_y.item(7);
    values.duck_4_b_x = list.ducks_x.item(8);
    values.duck_4_b_y = list.ducks_y.item(8);
    values.duck_5_a_x = list.ducks_x.item(9);
    values.duck_5_a_y = list.ducks_y.item(9);
    values.duck_5_b_x = list.ducks_x.item(10);
    values.duck_5_b_y = list.ducks_y.item(10);
]
/ stimulusframes = [1=clearscreen]
/ validresponse = (0)
/ trialduration = 1000
/ branch = [
    return trial.selectduck;
]
/ recorddata = false
</trial>

// same as above, for level four
<trial four>
/ ontrialbegin = [
    values.level = "four";
    values.target_n = 4;
    values.labelitem = 5;
    values.n_dropped = 0;
    values.ducks_dropped = "";
    
    list.responses.reset();
    list.ducks_x.reset();
    list.ducks_y.reset();
    list.ducks_skip.reset();
    values.duck_1_a_x = list.ducks_x.item(1);
    values.duck_1_a_y = list.ducks_y.item(1);
    values.duck_1_b_x = list.ducks_x.item(2);
    values.duck_1_b_y = list.ducks_y.item(2);
    values.duck_2_a_x = list.ducks_x.item(3);
    values.duck_2_a_y = list.ducks_y.item(3);
    values.duck_2_b_x = list.ducks_x.item(4);
    values.duck_2_b_y = list.ducks_y.item(4);
    values.duck_3_a_x = list.ducks_x.item(5);
    values.duck_3_a_y = list.ducks_y.item(5);
    values.duck_3_b_x = list.ducks_x.item(6);
    values.duck_3_b_y = list.ducks_y.item(6);
    values.duck_4_a_x = list.ducks_x.item(7);
    values.duck_4_a_y = list.ducks_y.item(7);
    values.duck_4_b_x = list.ducks_x.item(8);
    values.duck_4_b_y = list.ducks_y.item(8);
    values.duck_5_a_x = list.ducks_x.item(9);
    values.duck_5_a_y = list.ducks_y.item(9);
    values.duck_5_b_x = list.ducks_x.item(10);
    values.duck_5_b_y = list.ducks_y.item(10);
]
/ stimulusframes = [1=clearscreen]
/ validresponse = (0)
/ trialduration = 1000
/ branch = [
    return trial.selectduck;
]
/ recorddata = false
</trial>

// same as above, for level five
<trial five>
/ ontrialbegin = [
    values.level = "five";
    values.target_n = 5;
    values.labelitem = 6;
    values.n_dropped = 0;
    values.ducks_dropped = "";
    
    list.responses.reset();
    list.ducks_x.reset();
    list.ducks_y.reset();
    list.ducks_skip.reset();
    values.duck_1_a_x = list.ducks_x.item(1);
    values.duck_1_a_y = list.ducks_y.item(1);
    values.duck_1_b_x = list.ducks_x.item(2);
    values.duck_1_b_y = list.ducks_y.item(2);
    values.duck_2_a_x = list.ducks_x.item(3);
    values.duck_2_a_y = list.ducks_y.item(3);
    values.duck_2_b_x = list.ducks_x.item(4);
    values.duck_2_b_y = list.ducks_y.item(4);
    values.duck_3_a_x = list.ducks_x.item(5);
    values.duck_3_a_y = list.ducks_y.item(5);
    values.duck_3_b_x = list.ducks_x.item(6);
    values.duck_3_b_y = list.ducks_y.item(6);
    values.duck_4_a_x = list.ducks_x.item(7);
    values.duck_4_a_y = list.ducks_y.item(7);
    values.duck_4_b_x = list.ducks_x.item(8);
    values.duck_4_b_y = list.ducks_y.item(8);
    values.duck_5_a_x = list.ducks_x.item(9);
    values.duck_5_a_y = list.ducks_y.item(9);
    values.duck_5_b_x = list.ducks_x.item(10);
    values.duck_5_b_y = list.ducks_y.item(10);
]
/ stimulusframes = [1=clearscreen]
/ validresponse = (0)
/ trialduration = 1000
/ branch = [
    return trial.selectduck;
]
/ recorddata = false
</trial>

// same as above, for level six
<trial six>
/ ontrialbegin = [
    values.level = "six";
    values.target_n = 6;
    values.labelitem = 7;
    values.n_dropped = 0;
    values.ducks_dropped = "";
    
    list.responses.reset();
    list.ducks_x.reset();
    list.ducks_y.reset();
    list.ducks_skip.reset();
    values.duck_1_a_x = list.ducks_x.item(1);
    values.duck_1_a_y = list.ducks_y.item(1);
    values.duck_1_b_x = list.ducks_x.item(2);
    values.duck_1_b_y = list.ducks_y.item(2);
    values.duck_2_a_x = list.ducks_x.item(3);
    values.duck_2_a_y = list.ducks_y.item(3);
    values.duck_2_b_x = list.ducks_x.item(4);
    values.duck_2_b_y = list.ducks_y.item(4);
    values.duck_3_a_x = list.ducks_x.item(5);
    values.duck_3_a_y = list.ducks_y.item(5);
    values.duck_3_b_x = list.ducks_x.item(6);
    values.duck_3_b_y = list.ducks_y.item(6);
    values.duck_4_a_x = list.ducks_x.item(7);
    values.duck_4_a_y = list.ducks_y.item(7);
    values.duck_4_b_x = list.ducks_x.item(8);
    values.duck_4_b_y = list.ducks_y.item(8);
    values.duck_5_a_x = list.ducks_x.item(9);
    values.duck_5_a_y = list.ducks_y.item(9);
    values.duck_5_b_x = list.ducks_x.item(10);
    values.duck_5_b_y = list.ducks_y.item(10);
]
/ stimulusframes = [1=clearscreen]
/ validresponse = (0)
/ trialduration = 1000
/ branch = [
    return trial.selectduck;
]
/ recorddata = false
</trial>

// duck selection trial:
// this trial takes a click on any of the duck objects and then branches
// a trial displaying an animation of the selected duck moving to the pond
<trial selectduck>
/ ontrialbegin = [
    // update duck positions
    values.duck_1_a_x = list.ducks_x.item(1);
    values.duck_1_a_y = list.ducks_y.item(1);
    values.duck_1_b_x = list.ducks_x.item(2);
    values.duck_1_b_y = list.ducks_y.item(2);
    values.duck_2_a_x = list.ducks_x.item(3);
    values.duck_2_a_y = list.ducks_y.item(3);
    values.duck_2_b_x = list.ducks_x.item(4);
    values.duck_2_b_y = list.ducks_y.item(4);
    values.duck_3_a_x = list.ducks_x.item(5);
    values.duck_3_a_y = list.ducks_y.item(5);
    values.duck_3_b_x = list.ducks_x.item(6);
    values.duck_3_b_y = list.ducks_y.item(6);
    values.duck_4_a_x = list.ducks_x.item(7);
    values.duck_4_a_y = list.ducks_y.item(7);
    values.duck_4_b_x = list.ducks_x.item(8);
    values.duck_4_b_y = list.ducks_y.item(8);
    values.duck_5_a_x = list.ducks_x.item(9);
    values.duck_5_a_y = list.ducks_y.item(9);
    values.duck_5_b_x = list.ducks_x.item(10);
    values.duck_5_b_y = list.ducks_y.item(10);
]
/ stimulusframes = [1=clearscreen, instr, pond, duck_1_a, duck_1_b, duck_2_a, duck_2_b, duck_3_a, duck_3_b, duck_4_a, duck_4_b, duck_5_a, duck_5_b, continue, quit_ins]
/ inputdevice = mouse
/ validresponse = (duck_1_a, duck_1_b, duck_2_a, duck_2_b, duck_3_a, duck_3_b, duck_4_a, duck_4_b, duck_5_a, duck_5_b, continue)
/ isvalidresponse = [
    // response is valid if the duck hasn't been selected previously; continue button is always valid
    list.responses.indexof(trial.selectduck.response) == -1 || trial.selectduck.response == "continue";
]
/ ontrialend = [
    // if we had a duck selected (i.e. not a "continue" response)
    if (trial.selectduck.response != "continue") {
        list.responses.appenditem(trial.selectduck.response); // add the selected duck to the list of already given responses
        values.n_dropped += 1; // increase the count of selected ducks
        values.ducks_dropped = concat(concat(values.ducks_dropped, ","), trial.selectduck.response); // add name of selected duck object
        values.duck_index = list.ducks_object.indexof(trial.selectduck.response); // retrieve index of selected duck object
        values.anim_item = list.ducks_item.item(values.duck_index); // retrieve whether that duck was left or right facing
        values.anim_start_x = list.ducks_x.item(values.duck_index); // retrieve the duck's x position for use in the animation
        values.anim_start_y = list.ducks_y.item(values.duck_index); // same for y position
        values.anim_end_x = values.pond_x + round(rand(-10, 10)); // pick a random x position for the duck in the pond
        values.anim_end_y = values.pond_y + round(rand(-7, 7)); // same for y position
        list.ducks_x.setitem(values.anim_end_x, values.duck_index); // update the static duck object's x position
        list.ducks_y.setitem(values.anim_end_y, values.duck_index); // same for y position
        list.ducks_skip.setitem(true, values.duck_index); // make sure the static duck image is skipped during the animation trial
    };
]
/ branch = [
    if (trial.selectduck.response != "continue") { // if we selected a duck
        return trial.moveducktopond; // go to the animation trial
        } else { // otherwise
        return list.level_endtrial.item(list.level.indexof(values.level)); // go to the end trial for this level
    };
]
/ recorddata = false
</trial>

<trial moveducktopond>
/ ontrialbegin = [
    // make sure we skip the static duck image during the animation
    picture.duck_1_a.skip = list.ducks_skip.item(1);
    picture.duck_1_b.skip = list.ducks_skip.item(2);
    picture.duck_2_a.skip = list.ducks_skip.item(3);
    picture.duck_2_b.skip = list.ducks_skip.item(4);
    picture.duck_3_a.skip = list.ducks_skip.item(5);
    picture.duck_3_b.skip = list.ducks_skip.item(6);
    picture.duck_4_a.skip = list.ducks_skip.item(7);
    picture.duck_4_b.skip = list.ducks_skip.item(8);
    picture.duck_5_a.skip = list.ducks_skip.item(9);
    picture.duck_5_b.skip = list.ducks_skip.item(10);
]
/ ontrialend = [
    // revert the skipping of the static duck image
    list.ducks_skip.reset();
    picture.duck_1_a.skip = list.ducks_skip.item(1);
    picture.duck_1_b.skip = list.ducks_skip.item(2);
    picture.duck_2_a.skip = list.ducks_skip.item(3);
    picture.duck_2_b.skip = list.ducks_skip.item(4);
    picture.duck_3_a.skip = list.ducks_skip.item(5);
    picture.duck_3_b.skip = list.ducks_skip.item(6);
    picture.duck_4_a.skip = list.ducks_skip.item(7);
    picture.duck_4_b.skip = list.ducks_skip.item(8);
    picture.duck_5_a.skip = list.ducks_skip.item(9);
    picture.duck_5_b.skip = list.ducks_skip.item(10);
]
/ stimulusframes = [1=clearscreen, instr, pond, duck_1_a, duck_1_b, duck_2_a, duck_2_b, duck_3_a, duck_3_b, duck_4_a, duck_4_b, duck_5_a, duck_5_b, continue, quit_ins, duck_anim]
/ validresponse = (0)
/ trialduration = 1000
/ recorddata = false
/ branch = [
    if(values.n_dropped < 10) { // if there are more ducks that could be selected
        return trial.selectduck; // go back to the selection trial
    } else { // otherwise
        return list.level_endtrial.item(list.level.indexof(values.level)); // go to the end trial for this level
    };
]
</trial>

// end trial for level one
<trial one_end>
/ ontrialbegin = [
    // update the static image positions
    values.duck_1_a_x = list.ducks_x.item(1);
    values.duck_1_a_y = list.ducks_y.item(1);
    values.duck_1_b_x = list.ducks_x.item(2);
    values.duck_1_b_y = list.ducks_y.item(2);
    values.duck_2_a_x = list.ducks_x.item(3);
    values.duck_2_a_y = list.ducks_y.item(3);
    values.duck_2_b_x = list.ducks_x.item(4);
    values.duck_2_b_y = list.ducks_y.item(4);
    values.duck_3_a_x = list.ducks_x.item(5);
    values.duck_3_a_y = list.ducks_y.item(5);
    values.duck_3_b_x = list.ducks_x.item(6);
    values.duck_3_b_y = list.ducks_y.item(6);
    values.duck_4_a_x = list.ducks_x.item(7);
    values.duck_4_a_y = list.ducks_y.item(7);
    values.duck_4_b_x = list.ducks_x.item(8);
    values.duck_4_b_y = list.ducks_y.item(8);
    values.duck_5_a_x = list.ducks_x.item(9);
    values.duck_5_a_y = list.ducks_y.item(9);
    values.duck_5_b_x = list.ducks_x.item(10);
    values.duck_5_b_y = list.ducks_y.item(10);
]
/ stimulusframes = [1=clearscreen, instr, pond, duck_1_a, duck_1_b, duck_2_a, duck_2_b, duck_3_a, duck_3_b, duck_4_a, duck_4_b, duck_5_a, duck_5_b, continue, quit_ins]
/ validresponse = (0)
/ iscorrectresponse = [
    if (values.n_dropped == values.target_n) { // if we moved exactly as many ducks as we were supposed to
        return true; // we have a correct response
    } else { // otherwise
        return false; // we have an error
    }
]
/ trialduration = 250
/ branch = [
    if (trial.one_end.correct) { // if we had a correct response
        return trial.two; // we move up to level two
    } else { // otherwise
        return trial.one; // we stay at level one (ordinarily, we would move down one level, but there is no level zero)
    };
]
</trial>

// same as above, but for level two
<trial two_end>
/ ontrialbegin = [
    values.duck_1_a_x = list.ducks_x.item(1);
    values.duck_1_a_y = list.ducks_y.item(1);
    values.duck_1_b_x = list.ducks_x.item(2);
    values.duck_1_b_y = list.ducks_y.item(2);
    values.duck_2_a_x = list.ducks_x.item(3);
    values.duck_2_a_y = list.ducks_y.item(3);
    values.duck_2_b_x = list.ducks_x.item(4);
    values.duck_2_b_y = list.ducks_y.item(4);
    values.duck_3_a_x = list.ducks_x.item(5);
    values.duck_3_a_y = list.ducks_y.item(5);
    values.duck_3_b_x = list.ducks_x.item(6);
    values.duck_3_b_y = list.ducks_y.item(6);
    values.duck_4_a_x = list.ducks_x.item(7);
    values.duck_4_a_y = list.ducks_y.item(7);
    values.duck_4_b_x = list.ducks_x.item(8);
    values.duck_4_b_y = list.ducks_y.item(8);
    values.duck_5_a_x = list.ducks_x.item(9);
    values.duck_5_a_y = list.ducks_y.item(9);
    values.duck_5_b_x = list.ducks_x.item(10);
    values.duck_5_b_y = list.ducks_y.item(10);
]
/ stimulusframes = [1=clearscreen, instr, pond, duck_1_a, duck_1_b, duck_2_a, duck_2_b, duck_3_a, duck_3_b, duck_4_a, duck_4_b, duck_5_a, duck_5_b, continue, quit_ins]
/ validresponse = (0)
/ iscorrectresponse = [if (values.n_dropped == values.target_n) true else false]
/ trialduration = 250
/ branch = [
    if (trial.two_end.correct) {
        return trial.three;
    } else {
        return trial.one;
    };
]
</trial>

// same as above, but for level three
<trial three_end>
/ ontrialbegin = [
    values.duck_1_a_x = list.ducks_x.item(1);
    values.duck_1_a_y = list.ducks_y.item(1);
    values.duck_1_b_x = list.ducks_x.item(2);
    values.duck_1_b_y = list.ducks_y.item(2);
    values.duck_2_a_x = list.ducks_x.item(3);
    values.duck_2_a_y = list.ducks_y.item(3);
    values.duck_2_b_x = list.ducks_x.item(4);
    values.duck_2_b_y = list.ducks_y.item(4);
    values.duck_3_a_x = list.ducks_x.item(5);
    values.duck_3_a_y = list.ducks_y.item(5);
    values.duck_3_b_x = list.ducks_x.item(6);
    values.duck_3_b_y = list.ducks_y.item(6);
    values.duck_4_a_x = list.ducks_x.item(7);
    values.duck_4_a_y = list.ducks_y.item(7);
    values.duck_4_b_x = list.ducks_x.item(8);
    values.duck_4_b_y = list.ducks_y.item(8);
    values.duck_5_a_x = list.ducks_x.item(9);
    values.duck_5_a_y = list.ducks_y.item(9);
    values.duck_5_b_x = list.ducks_x.item(10);
    values.duck_5_b_y = list.ducks_y.item(10);
]
/ stimulusframes = [1=clearscreen, instr, pond, duck_1_a, duck_1_b, duck_2_a, duck_2_b, duck_3_a, duck_3_b, duck_4_a, duck_4_b, duck_5_a, duck_5_b, continue, quit_ins]
/ validresponse = (0)
/ iscorrectresponse = [if (values.n_dropped == values.target_n) true else false]
/ trialduration = 250
/ branch = [
    if (trial.three_end.correct) {
        return trial.four;
    } else {
        return trial.two;
    };
]
</trial>

// same as above, but for level four
<trial four_end>
/ ontrialbegin = [
    values.duck_1_a_x = list.ducks_x.item(1);
    values.duck_1_a_y = list.ducks_y.item(1);
    values.duck_1_b_x = list.ducks_x.item(2);
    values.duck_1_b_y = list.ducks_y.item(2);
    values.duck_2_a_x = list.ducks_x.item(3);
    values.duck_2_a_y = list.ducks_y.item(3);
    values.duck_2_b_x = list.ducks_x.item(4);
    values.duck_2_b_y = list.ducks_y.item(4);
    values.duck_3_a_x = list.ducks_x.item(5);
    values.duck_3_a_y = list.ducks_y.item(5);
    values.duck_3_b_x = list.ducks_x.item(6);
    values.duck_3_b_y = list.ducks_y.item(6);
    values.duck_4_a_x = list.ducks_x.item(7);
    values.duck_4_a_y = list.ducks_y.item(7);
    values.duck_4_b_x = list.ducks_x.item(8);
    values.duck_4_b_y = list.ducks_y.item(8);
    values.duck_5_a_x = list.ducks_x.item(9);
    values.duck_5_a_y = list.ducks_y.item(9);
    values.duck_5_b_x = list.ducks_x.item(10);
    values.duck_5_b_y = list.ducks_y.item(10);
]
/ stimulusframes = [1=clearscreen, instr, pond, duck_1_a, duck_1_b, duck_2_a, duck_2_b, duck_3_a, duck_3_b, duck_4_a, duck_4_b, duck_5_a, duck_5_b, continue, quit_ins]
/ validresponse = (0)
/ iscorrectresponse = [if (values.n_dropped == values.target_n) true else false]
/ trialduration = 250
/ branch = [
    if (trial.four_end.correct) {
        return trial.five;
    } else {
        return trial.three;
    };
]
</trial>

// same as above, but for level five
<trial five_end>
/ ontrialbegin = [
    values.duck_1_a_x = list.ducks_x.item(1);
    values.duck_1_a_y = list.ducks_y.item(1);
    values.duck_1_b_x = list.ducks_x.item(2);
    values.duck_1_b_y = list.ducks_y.item(2);
    values.duck_2_a_x = list.ducks_x.item(3);
    values.duck_2_a_y = list.ducks_y.item(3);
    values.duck_2_b_x = list.ducks_x.item(4);
    values.duck_2_b_y = list.ducks_y.item(4);
    values.duck_3_a_x = list.ducks_x.item(5);
    values.duck_3_a_y = list.ducks_y.item(5);
    values.duck_3_b_x = list.ducks_x.item(6);
    values.duck_3_b_y = list.ducks_y.item(6);
    values.duck_4_a_x = list.ducks_x.item(7);
    values.duck_4_a_y = list.ducks_y.item(7);
    values.duck_4_b_x = list.ducks_x.item(8);
    values.duck_4_b_y = list.ducks_y.item(8);
    values.duck_5_a_x = list.ducks_x.item(9);
    values.duck_5_a_y = list.ducks_y.item(9);
    values.duck_5_b_x = list.ducks_x.item(10);
    values.duck_5_b_y = list.ducks_y.item(10);
]
/ stimulusframes = [1=clearscreen, instr, pond, duck_1_a, duck_1_b, duck_2_a, duck_2_b, duck_3_a, duck_3_b, duck_4_a, duck_4_b, duck_5_a, duck_5_b, continue, quit_ins]
/ validresponse = (0)
/ iscorrectresponse = [if (values.n_dropped == values.target_n) true else false]
/ trialduration = 250
/ branch = [
    if (trial.five_end.correct) {
        return trial.six;
    } else {
        return trial.four;
    };
]
</trial>

// same as above, but for level six
<trial six_end>
/ ontrialbegin = [
    values.duck_1_a_x = list.ducks_x.item(1);
    values.duck_1_a_y = list.ducks_y.item(1);
    values.duck_1_b_x = list.ducks_x.item(2);
    values.duck_1_b_y = list.ducks_y.item(2);
    values.duck_2_a_x = list.ducks_x.item(3);
    values.duck_2_a_y = list.ducks_y.item(3);
    values.duck_2_b_x = list.ducks_x.item(4);
    values.duck_2_b_y = list.ducks_y.item(4);
    values.duck_3_a_x = list.ducks_x.item(5);
    values.duck_3_a_y = list.ducks_y.item(5);
    values.duck_3_b_x = list.ducks_x.item(6);
    values.duck_3_b_y = list.ducks_y.item(6);
    values.duck_4_a_x = list.ducks_x.item(7);
    values.duck_4_a_y = list.ducks_y.item(7);
    values.duck_4_b_x = list.ducks_x.item(8);
    values.duck_4_b_y = list.ducks_y.item(8);
    values.duck_5_a_x = list.ducks_x.item(9);
    values.duck_5_a_y = list.ducks_y.item(9);
    values.duck_5_b_x = list.ducks_x.item(10);
    values.duck_5_b_y = list.ducks_y.item(10);
]
/ stimulusframes = [1=clearscreen, instr, pond, duck_1_a, duck_1_b, duck_2_a, duck_2_b, duck_3_a, duck_3_b, duck_4_a, duck_4_b, duck_5_a, duck_5_b, continue, quit_ins]
/ validresponse = (0)
/ iscorrectresponse = [if (values.n_dropped == values.target_n) true else false]
/ trialduration = 250
/ branch = [
    if (trial.six_end.correct) {
        return trial.six;
    } else {
        return trial.five;
    };
]
</trial>

******ITEMS***********
<item stimuli>
/1 = "duck_1.png"
/2 = "duck_2.png"
/3 = "pond.png"
/4 = "continue_button.png"
</item>

<picture pond>
/items = stimuli
/select = 3
/size = (60%,40%)
/hposition = 75%
/vposition = 50%
/ erase = false
</picture>

<picture continue>
/ items = stimuli
/ select = 4
/ position = (80%, 80%)
/ erase = false
</picture>

// the animated duck object
<picture duck_anim>
/items = stimuli
/select = values.anim_item
/size = (15%,15%)
/ animation = path(1000, 1, values.anim_start_x, values.anim_start_y, values.anim_end_x, values.anim_end_y)
/ erase = false
</picture>

<picture duck_1_a>
/items = stimuli
/select = 1
/size = (15%,15%)
/ hposition = values.duck_1_a_x
/ vposition = values.duck_1_a_y
/ erase = false
</picture>

<picture duck_1_b>
/items = stimuli
/select = 2
/size = (15%,15%)
/ hposition = values.duck_1_b_x
/ vposition = values.duck_1_b_y
/ erase = false
</picture>

<picture duck_2_a>
/items = stimuli
/select = 1
/size = (15%,15%)
/ hposition = values.duck_2_a_x
/ vposition = values.duck_2_a_y
/ erase = false
</picture>

<picture duck_2_b>
/items = stimuli
/select = 2
/size = (15%,15%)
/ hposition = values.duck_2_b_x
/ vposition = values.duck_2_b_y
/ erase = false
</picture>

<picture duck_3_a>
/items = stimuli
/select = 1
/size = (15%,15%)
/ hposition = values.duck_3_a_x
/ vposition = values.duck_3_a_y
/ erase = false
</picture>

<picture duck_3_b>
/items = stimuli
/select = 2
/size = (15%,15%)
/ hposition = values.duck_3_b_x
/ vposition = values.duck_3_b_y
/ erase = false
</picture>

<picture duck_4_a>
/items = stimuli
/select = 1
/size = (15%,15%)
/ hposition = values.duck_4_a_x
/ vposition = values.duck_4_a_y
/ erase = false
</picture>

<picture duck_4_b>
/items = stimuli
/select = 2
/size = (15%,15%)
/ hposition = values.duck_4_b_x
/ vposition = values.duck_4_b_y
/ erase = false
</picture>

<picture duck_5_a>
/items = stimuli
/select = 1
/size = (15%,15%)
/ hposition = values.duck_5_a_x
/ vposition = values.duck_5_a_y
/ erase = false
</picture>

<picture duck_5_b>
/items = stimuli
/select = 2
/size = (15%,15%)
/ hposition = values.duck_5_b_x
/ vposition = values.duck_5_b_y
/ erase = false
</picture>

<text instr>
/items = labels
/select = values.labelitem
/vposition = 90%
/hposition = 50%
/color = black
/fontstyle = ("Heiti TC", 4.00%, false, false, false, false, 5, 0)
/ erase = false
</text>

<text quit_ins>
/ items = labels
/ select = 13
/ vposition = 85%
/ hposition = 50%
/ color = black
/ fontstyle = ("Times New Roman", 1.80%, false, false, true, false, 5, 1)
/ erase = false
</text>

<text thank_you>
/items = labels
/select = 12
/vposition = 50%
/hposition = 50%
/color = black
/fontstyle = ("Heiti TC", 4.00%, false, false, false, false, 5, 0)
/ erase = false
</text>

<item labels>
/1 = "If I want to make a duck jump in the pond, I go like this."
/2 = "Can you make 1 duck jump in the pond?"
/3 = "Can you make 2 ducks jump in the pond?"
/4 = "Can you make 3 ducks jump in the pond?"
/5 = "Can you make 4 ducks jump in the pond?"
/6 = "Can you make 5 ducks jump in the pond?"
/7 = "Can you make 6 ducks jump in the pond?"
/8 = "Continue"
/9 = "Try Again"
/10 = "next"
/11 = "previous"
/12 = "Thank you for playing! Click anywhere on the screen to exit"
/13 = "*Note: if you want to quit the game at any time, please press 'Ctrl+Q' (Windows) / 'Command+Q' (Apple) on your keyboard."
</item>