Psychtoolbox / Matalb : To click the mouse several times

2 views (last 30 days)
I know how to make Filoval appear. Just focus on the mouse problem.
If 4 'Filloval' appear, you must select all 4 ovals.
If 1 oval is selected 4 times, only 1 oval is selected, so it should not be terminated.
However, if you look at my code, it will be over even if you press 1 oval 4 times
So we created a matrix, and if we click on one oval,
we're going to erase the column that corresponds to one oval so that it doesn't end if we press one oval in duplicate.
The problem is that if you click one oval in the (14) matrix to create a (13) matrix, the (13) matrix must be maintained, but it does not.
for mouse = 1 : 4 % mouse 4 click
ShowCursor (0);
SetMouse(xCenter, yCenter*1.9, windowPtr);
click = 1;
while click == 1;
[xMouse, yMouse, buttons] = GetMouse(windowPtr);
inside1 = IsInRect(xMouse, yMouse, Tchoicecenter);
inside2 = IsInRect(xMouse, yMouse, Tchoicecenter2);
inside3 = IsInRect(xMouse, yMouse, Tchoicecenter3);
inside4 = IsInRect(xMouse, yMouse, Tchoicecenter4);
if inside1 == 1
Rectlocation(:,mouse) = Tchoicecenter;
if any(buttons)
break
end
elseif inside2 == 1
Rectlocation(:,mouse) = Tchoicecenter2;
if any(buttons)
break
end
elseif inside3 == 1
Rectlocation(:,mouse) = Tchoicecenter3;
if any(buttons)
break
end
elseif inside4 == 1
Rectlocation(:,mouse) = Tchoicecenter4;
if any(buttons)
break
end
end
Tovalcenter = CenterRectOnPoint(ovalBaseRect, TXpos, TYpos);
Tovalcenter2 = CenterRectOnPoint(ovalBaseRect, TXpos2, TYpos2);
Tovalcenter3 = CenterRectOnPoint(ovalBaseRect, TXpos3, TYpos3);
Tovalcenter4 = CenterRectOnPoint(ovalBaseRect, TXpos4, TYpos4);
Screen('FillOval', windowPtr, TColor, Tovalcenter);
Screen('FillOval', windowPtr, TColor, Tovalcenter2);
Screen('FillOval', windowPtr, TColor, Tovalcenter3);
Screen('FillOval', windowPtr, TColor, Tovalcenter4);
end
mouseans = [1:4 ; inside1 inside2 inside3 inside4];
a = find(mouseans(2,:) == 1); % mouse click (True == 1)
mouseans(:,a) = []
end
<result>
mouseans = 1 3 4 % 2 oval click
0 0 0
mouseans = 1 2 3 % 4 oval click
0 0 0
mouseans = 1 2 4 % 3 oval click
0 0 0
mouseans = 2 3 4 % 1 oval click
0 0 0
<my hope
result>
mouseans = 1 3 4 % 2 oval click
0 0 0
mouseans = 1 3 % 4 oval click
0 0
mouseans = 1 % 3 oval click
0
mouseans = [] % 1 oval click
I don't know what to do anymore.
Please help me to click all 4 ovals to finish.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!