Skip to content

Instantly share code, notes, and snippets.

@smithdanielle
Last active August 29, 2015 14:15
Show Gist options
  • Save smithdanielle/9cfffa12eb9db652b413 to your computer and use it in GitHub Desktop.
Save smithdanielle/9cfffa12eb9db652b413 to your computer and use it in GitHub Desktop.
Making psychophysics marginally less boring for children; find image file [here](http://imgur.com/PswTGzw)
runNum = input('run number: ');
% Load rocket image
endRocket.load = imread('rocket2.png');
endRocket.texture = Screen('MakeTexture', windowPtr, endRocket.load);
% Get the size of the image
[s1, s2, s3] = size(endRocket.load);
% Get the aspect ratio of the image. We need this to maintain the aspect
% ratio of the image when we draw it different sizes. Otherwise, if we
% don't match the aspect ratio the image will appear warped / stretched
endRocket.aspectRatio = s2 / s1;
endRocket.heightScalers= 0.5;
endRocket.imageHeights = screenParams.Res(2) .* endRocket.heightScalers;
endRocket.imageWidths = endRocket.imageHeights .* endRocket.aspectRatio;
endRocket.theRect = [0 0 endRocket.imageWidths endRocket.imageHeights];
endRocket.dstRects = CenterRectOnPointd(endRocket.theRect, xcen,...
ycen+(0.25*endRocket.imageHeights));
endText = ['EXPEDITION ', num2str(runNum), ' OF 4 \n COMPLETE'];
% Prepare the end screen
% Select left-eye image buffer for drawing:
Screen('SelectStereoDrawBuffer', windowPtr, 0);
Screen('FillRect', windowPtr, [90 90 90]);
Screen('TextFont',windowPtr, 'Arial');
Screen('TextSize',windowPtr, 90);
DrawFormattedText(windowPtr, endText,'center',50,white,[],flipHorizontal=1);
Screen('DrawTextures', windowPtr, endRocket.texture, [], endRocket.dstRects);
% Select right-eye image buffer for drawing:
Screen('SelectStereoDrawBuffer', windowPtr, 1);
Screen('FillRect', windowPtr, [0 0 0]);
Screen('TextFont',windowPtr, 'Arial');
Screen('TextSize',windowPtr, 90);
DrawFormattedText(windowPtr, endText,'center',50,white,[],flipHorizontal=1);
Screen('DrawTextures', windowPtr, endRocket.texture, [], endRocket.dstRects);
% Now show the end screen
Screen(windowPtr,'Flip');
% Wait for response: should be q key
keyIsDown = 0;
while(~keyIsDown || (~keyCode(q) && ~keyCode(escapeKey)))
[keyIsDown,secs,keyCode] = KbCheck(-3);
% Returns keyboard status, time, keycode
end
keyIsDown = 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment