accelerating Wheel - psychtoolbox in matlab

Posted by ariel on Stack Overflow See other posts from Stack Overflow or by ariel
Published on 2010-04-10T19:24:29Z Indexed on 2010/04/10 19:33 UTC
Read the original article Hit count: 447

Hi
I am trying to write a code that will show an acceleration wheel. as long as the user press 'a' the wheel should accelerate counterclock wize. the thing is that it turn in the right direction but it doesn't accelerate. This is the code I am using . PTB-3 windows XP.

img=imread('c:\images.jpg');
[yimg,ximg,z]=size(img);
rot_spd = 1;
larrow = KbName('a'); % modify this for Windows
rarrow = KbName('b');
[w,rect]=Screen('OpenWindow',0,[0 0 0]);
sx = 400; % desired x-size of image (pixels)
sy = yimg*sx/ximg; % desired y-size--keep proportional
t = Screen('MakeTexture',w,img);
bdown=0;
th = 0; % initial rotation angle (degrees)
HideCursor
while(~any(bdown)) % exit loop if mouse button is pressed
[x,y,bdown]=GetMouse;
[keyisdown,secs,keycode] = KbCheck;
if(keycode(larrow))
th = th - rot_spd-1; % accelerate counterclockwise
th
end
if(keycode(rarrow))
th = th + rot_spd+1; % accelerate clockwise
th
end
destrect=[x-sx/2,y-sy/2,x+sx/2,y+sy/2];
Screen('DrawTexture',w,t,[],destrect,th);
Screen('Flip',w);
end
Screen('Close',w)
ShowCursor

If anyone has an odea why it doesn't accelerate I'd appriciate it very much.

Ariel

© Stack Overflow or respective owner

Related posts about matlab

Related posts about programming-psychology