0

I am writing a piece of experiment code and am stuck at this piece of code.

The idea is to display two images with text below them. Participants will have to select between these options.

I have assigned 'z' for keyboard and 'm' for joystick.

My questions are: 1. What is wrong with While loop? 2. does anyone know a way of creating four selection boxes under the images which can be highlighted via mouse or keyboard arrows?

for trials = 1:16 Screen ('FillRect', mainwin, bgcolor);

% Display keyboard and joystick images
Screen('DrawTexture', mainwin, keyboard, [], leftRect);
Screen('DrawTexture', mainwin, joystick, [], rightRect);
Screen('DrawText',mainwin,['Welcome to the Experiment!'] ,xCenter+150, yCenter+100,textcolor);
Screen('DrawText',mainwin,['Press z to select mental effort or m for physical effort.'] ,xCenter+350, yCenter+500,textcolor);
Screen('Flip', mainwin);
WaitSecs(3);

keyIsDown=0;
while 1
[keyIsDown, secs, keyCode] = KbCheck;
if keyIsDown;
    %checking which keyboard input has been pressed
    if keyCode(Key1);
        Screen('DrawTexture', mainwin, keyboard, [], leftRect);
    elseif keyCode(Key2);
        Screen('DrawTexture', mainwin, joystick, [], rightRect);
        break;
    else keyCode(escKey)
        ShowCursor;
        fclose(outfile);
        Screen('CloseAll');
        return;
    end
end 
end 
 trialorder = Shuffle(1:nTrialsPerGroup); % randomize trial order for each block

end

Y. Lin
  • 1
  • 2

0 Answers0