%(x0,y0) ---initial position of the pacman
%(x1,y1) ---target position of the pacman
%count  ---the number of the drawings
%color_dim---color of the pacman
%

function erasepacman(x0,y0,x1,y1,count,color_dim)
global bigMatrixImg;
global background_Img;
image_rows=40;   %the number of the rows of pixels in one frame; 
image_cols=40;   %the number of the colomns of pixels in one frame;

body_row_center=image_rows./2+y0.*image_rows+image_rows./8.*count*(y1-y0);  %the y coordinates of the center of the pacman body.
body_col_center=image_cols./2+x0.*image_cols+image_cols./8.*count*(x1-x0);  %the x coordinates of the center of the pacman body.

    for i=ceil(body_row_center-image_rows/2+4):1:ceil(body_row_center+image_rows/2-4)
        for j=ceil(body_col_center-image_cols/2+4):1:ceil(body_col_center+image_cols/2-4)
            if(i>0 & j>0 & i<240 & j<320)
                if(color_dim==1)                     
                      bigMatrixImg(i,j,1) =0;background_Img(i,j,1)=0;
                      bigMatrixImg(i,j,2) =0;background_Img(i,j,2)=0;
                      bigMatrixImg(i,j,3) =0;background_Img(i,j,3)=0; 
                else
                      bigMatrixImg(i,j,1) =background_Img(i,j,1);
                      bigMatrixImg(i,j,2) =background_Img(i,j,2);
                      bigMatrixImg(i,j,3) =background_Img(i,j,3);
                end
            end
        end
    end
