仿真程序动画作品-跳格子

2022-01-10 20:14 阅读(?)评论(0)
%作者:1904020075 
clear;
hold on
axis off
text(3,4,'跳格子');
a1=plot([1 3],[0 0],'b','LineWidth',3);
a2=plot([1 1],[0 1],'b','LineWidth',3);
a3=plot([1 3],[1 1],'b','LineWidth',3);
a4=plot([3 3],[0 1],'b','LineWidth',3);
a5=plot([1 1],[1 2],'b','LineWidth',3);
a6=plot([3 3],[1 2],'b','LineWidth',3);
a7=plot([0 2],[2 2],'b','LineWidth',3);
a8=plot([2 4],[2 2],'b','LineWidth',3);
a9=plot([0 0],[2 3],'b','LineWidth',3);
a10=plot([2 2],[2 3],'b','LineWidth',3);
a11=plot([4 4],[2 3],'b','LineWidth',3);
a12=plot([1 1],[3 4],'b','LineWidth',3);
a13=plot([3 3],[3 4],'b','LineWidth',3);
a14=plot([1 3],[4 4],'b','LineWidth',3);
a15=plot([2 4],[3 3],'b','LineWidth',3);
a16=plot([0 2],[3 3],'b','LineWidth',3);
a17=plot([1 3],[3 3],'b','LineWidth',3);%画格子
fill([1 1 3 3],[0 1 1 0],'r');
pause(1);
fill([1 1 3 3],[1 2 2 1],'r');
fill([1 1 3 3],[0 1 1 0],'w');
pause(1);
fill([0 0 2 2],[2 3 3 2],'r');
fill([2 2 4 4],[2 3 3 2],'r');
fill([1 1 3 3],[1 2 2 1],'w');
pause(1);
fill([1 1 3 3],[3 4 4 3],'r');
fill([0 0 2 2],[2 3 3 2],'w');
fill([2 2 4 4],[2 3 3 2],'w');
pause(1);
fill([1 1 3 3],[3 4 4 3],'w');%模拟游戏过程
a18=plot([1.5 2.5],[0 1],'b','LineWidth',3);
a19=plot([2 2.5],[0.5 0],'b','LineWidth',3);%画人
dt=1;
t1=2;
t2=0.5;
while t2<=4
t2=t2+dt;
x1=t1;
y1=t2;
set(a18,'xdata',[x1-0.5 x1+0.5],'ydata',[y1-1.5 y1-0.5]);%循环移动人
set(a19,'xdata',[x1 x1+0.5],'ydata',[y1-1 y1-1.5]);
pause(1);
drawnow;
end;
hold off


  最后修改于 2022-01-13 19:36    阅读(?)评论(0)
 
表  情:
加载中...
 

请各位遵纪守法并注意语言文明