华容道小游戏Word下载.docx

上传人:b****7 文档编号:22635650 上传时间:2023-02-05 格式:DOCX 页数:25 大小:68.30KB
下载 相关 举报
华容道小游戏Word下载.docx_第1页
第1页 / 共25页
华容道小游戏Word下载.docx_第2页
第2页 / 共25页
华容道小游戏Word下载.docx_第3页
第3页 / 共25页
华容道小游戏Word下载.docx_第4页
第4页 / 共25页
华容道小游戏Word下载.docx_第5页
第5页 / 共25页
点击查看更多>>
下载资源
资源描述

华容道小游戏Word下载.docx

《华容道小游戏Word下载.docx》由会员分享,可在线阅读,更多相关《华容道小游戏Word下载.docx(25页珍藏版)》请在冰豆网上搜索。

华容道小游戏Word下载.docx

%*SeeGUIOptionsonGUIDE'

sToolsmenu.Choose"

GUIallowsonlyone

%instancetorun(singleton)"

.

%Seealso:

GUIDE,GUIDATA,GUIHANDLES

%Edittheabovetexttomodifytheresponsetohelpuntitled

%LastModifiedbyGUIDEv2.518-Jul-201823:

26:

39

%Begininitializationcode-DONOTEDIT

gui_Singleton=1;

gui_State=struct('

gui_Name'

mfilename,...

'

gui_Singleton'

gui_Singleton,...

gui_OpeningFcn'

@untitled_OpeningFcn,...

gui_OutputFcn'

@untitled_OutputFcn,...

gui_LayoutFcn'

[],...

gui_Callback'

[]);

ifnargin&

&

ischar(varargin{1})

gui_State.gui_Callback=str2func(varargin{1});

end

ifnargout

[varargout{1:

nargout}]=gui_mainfcn(gui_State,varargin{:

});

else

gui_mainfcn(gui_State,varargin{:

%Endinitializationcode-DONOTEDIT

 

%---Executesjustbeforeuntitledismadevisible.

functionuntitled_OpeningFcn(hObject,eventdata,handles,varargin)

%Thisfunctionhasnooutputargs,seeOutputFcn.

%hObjecthandletofigure

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

%varargincommandlineargumentstountitled(seeVARARGIN)

%Choosedefaultcommandlineoutputforuntitled

handles.output=hObject;

%Updatehandlesstructure

guidata(hObject,handles);

%UIWAITmakesuntitledwaitforuserresponse(seeUIRESUME)

%uiwait(handles.figure1);

%---Outputsfromthisfunctionarereturnedtothecommandline.

functionvarargout=untitled_OutputFcn(hObject,eventdata,handles)

%varargoutcellarrayforreturningoutputargs(seeVARARGOUT);

%Getdefaultcommandlineoutputfromhandlesstructure

varargout{1}=handles.output;

%---Executesonbuttonpressinpushbutton1.

functionpushbutton1_Callback(hObject,eventdata,handles)

globalA;

A=[2113;

2113;

4665;

4775;

7007];

cla

holdon

%在1的位置上写上曹操

[IJ]=find(A==1);

x1=min(J)-1;

x2=max(J);

y1=5-(min(I)-1);

y2=5-max(I);

drawrect([x1,y1],[x2,y1],[x2,y2],[x1,y2],'

r'

text(0.5*(x1+x2)-0.5,0.5*(y1+y2),'

曹操'

fontsize'

28)

%在2的位置上写上黄忠

[I,J]=find(A==2);

y'

text(0.5*(x1+x2)-0.26,0.5*(0.5*(y1+y2)+y1),'

黄'

text(0.5*(x1+x2)-0.26,0.5*(0.5*(y1+y2)+y2),'

忠'

%在3的位置上写上张飞

[I,J]=find(A==3);

张'

飞'

%在4的位置上写上马超

[I,J]=find(A==4);

马'

超'

%在5的位置上写上赵云

[I,J]=find(A==5);

赵'

云'

%在6的位置上写上关羽

[I,J]=find(A==6);

text(0.5*(x1+0.5*(x1+x2))-0.26,0.5*(y1+y2),'

关'

text(0.5*(0.5*(x1+x2)+x2)-0.26,0.5*(y1+y2),'

羽'

%在7的位置上写上小卒

[I,J]=find(A==7);

fori=1:

length(I)

x1=J(i)-1;

x2=J(i);

y1=5-(I(i)-1);

y2=5-I(i);

drawrect([x1,y1],[x2,y1],[x2,y2],[x1,y2],'

g'

text(0.5*(x1+x2)-0.26,0.5*(y1+y2),'

卒'

%画背景

line([04],[00],'

color'

b'

linewidth'

4)

line([04],[55],'

line([00],[05],'

line([44],[05],'

4

line([04],[ii],'

linestyle'

--'

3

line([ii],[05],'

axisequal

axis([0405])

axisoff

functiondrawrect(x1,x2,x3,x4,color)

x=[x1

(1)x2

(1)x3

(1)x4

(1)];

y=[x1

(2)x2

(2)x3

(2)x4

(2)];

fill(x,y,color)

%hObjecthandletopushbutton1(seeGCBO)

%---Executesonmousepressoveraxesbackground.

functionaxes1_ButtonDownFcn(hObject,eventdata,handles)

%hObjecthandletoaxes1(seeGCBO)

%---Executesduringobjectcreation,aftersettingallproperties.

functionaxes1_CreateFcn(hObject,eventdata,handles)

%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled

%Hint:

placecodeinOpeningFcntopopulateaxes1

%---Executesonbuttonpressinpushbutton2.

functionpushbutton2_Callback(hObject,eventdata,handles)

step_number=0;

globalA

while1

str=[num2str(step_number),'

步'

];

set(handles.edit2,'

string'

str);

ifA(5,2)==1&

A(5,3)==1

ch=menu('

曹操成功逃出华容道!

如果要继续玩,按“是”,否则按“否”'

是'

否'

);

switchch

case1

untitled

case2

return

end

[xpos,ypos]=ginput

(1);

col=ceil(xpos);

row=5-ceil(ypos)+1;

juese=A(row,col);

switchjuese

case1%点击了曹操

[I,J]=find(A==1);

rm=max(I);

rn=min(I);

lm=max(J);

ln=min(J);

%判断是否能向左移

ifln>

1&

A([rn,rm],ln-1)==[0;

0]

A([rn,rm],ln-1)=[1;

1];

A([rn,rm],lm)=[0;

0];

drawmap(A)

step_number=step_number+1;

%判断是否能向右移

iflm<

4&

A([rn,rm],lm+1)==[0;

A([rn,rm],lm+1)=[1;

A([rn,rm],ln)=[0;

%判断是否能向下移

ifrn>

(A(rn-1,[ln,lm])==[0,0])

A(rn-1,[ln,lm])=[1,1];

A(rn+1,[ln,lm])=[0,0];

%判断是否能向上移

ifrm<

5&

A(rm+1,[ln,lm])==[0,0]

A(rm+1,[ln,lm])=[1,1];

A(rm-1,[ln,lm])=[0,0];

case2%点击了黄忠

[I,J]=find(A==2);

A([rn,rm],ln-1)=[2;

2];

A([rn,rm],lm+1)=[2;

A(rn-1,ln)==0

A(rm+1,ln)==0%如果又能上移又能下移,则要点击的部位

ch=menu('

请选择移到的方向:

'

上'

下'

case1%上移

A(rn-1,ln)=2;

A(rn+1,ln)=0;

case2%下移

A(rm+1,ln)=2;

A(rm-1,ln)=0;

else%只能上移

elseifrm<

A(rm+1,ln)==0

case3%张飞

[I,J]=find(A==3);

(A([rn,rm],ln-1)==[0;

0])

A([rn,rm],ln-1)=[3;

3];

A([rn,rm],lm+1)=[3;

A(rn-1,ln)=3;

A(rm+1,ln)=3;

case4%马超

[I,J]=find(A==4);

A([rn,rm],ln-1)=[4;

4];

A([rn,rm],lm+1)=[4;

A(rm+1,ln)==0%如果又能上移又能下移,则要点击的部位

A(rn-1,ln)=4;

A(rm+1,ln)=4;

step_number=step_number+1

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1