123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- function [Ob, Par] = JA_Object_Movement(Par, Ob, arg)
- %% trial starts --> ball falls down --> when touches the table_CF it
- %% set parameters
- player = arg.player;
- distanceY = arg.distanceY;
- distanceX = arg.distanceX;
- % object to be moved
- target_object = 'ball';
- % create an internal variable and call it tobj
- tobj = Ob.(target_object);
- % % how long does it takes for the ball to land
- if isfield(arg, 'duration')
- duration = arg.duration;
- else
- duration = 0.5;
- end
- %% transform displacement into pixels
- distance_tmp = JA_prop2dim(Par.screen_dimensions, 0, distanceX);
- distanceX = distance_tmp(2);
- clear distance_ball_tmp;
- distance_tmp = JA_prop2dim(Par.screen_dimensions, 0, distanceY);
- distanceY = distance_tmp(2);
- clear distance_ball_tmp;
- %%
- [ifi_af,...
- ifi_as,...
- ifi_nf,...
- ifi_ns] = JA_frames_function(Par.ifi, Par.ifi);
- %% trasform in nominal and actual frames
- [ball_tw_actual_frames,...
- ball_tw_actual_seconds,...
- ball_tw_nominal_frames,...
- ball_tw_nominal_seconds] = JA_frames_function(duration, Par.ifi);
- %% set the step
- step_vert = distanceY/ball_tw_nominal_frames;
- step_lat = distanceX/ball_tw_nominal_frames;
- %% start falling for 'ball_tw_nominal_frames'
- for t = 1:ball_tw_nominal_frames
-
-
- %% increment displacement of the step specified
- tmp = tobj.dimension;
-
- tobj.dimension = ([tmp(1)+step_lat,...
- tmp(2)+step_vert,...
- tmp(3)+step_lat,...
- tmp(4)+step_vert]);
-
- tobj.centered_square = [tobj.centered_square(1)+step_lat, tobj.centered_square(2)+step_vert];
-
- % return the tobj value to the Ob, so that it could be
- % returned as output.
- Ob.(target_object) = tobj;
-
- % display the displacement on the screen (load all the objects in the screen)
- [Ob, Par] = JA_Load_Obj_On_Screen(Par, Ob);
-
- [Par.VBL] = Screen(Par.window, 'Flip', Par.VBL+ifi_as);
-
-
- if (t == 1)
-
- switch player
- case 'CF'
- Par.VBL_ball_falls_CF{Par.tr} = Par.VBL;
- case 'SBJ'
- Par.VBL_ball_falls_SBJ{Par.tr} = Par.VBL;
- end
-
- end
-
-
- % if the number of frames has reached the limit
- if (t == ball_tw_nominal_frames)
-
- switch player
- case 'CF'
- Par.VBL_ball_landed_on_table_CF{Par.tr} = Par.VBL;
- case 'SBJ'
- Par.VBL_ball_landed_on_table_SBJ{Par.tr} = Par.VBL;
- end
-
- end
-
- end
- end
- %[cell2mat(Par.VBL_ball_landed_on_table_CF) - cell2mat(Par.VBL_first_frame)]
|