ImageVerifierCode 换一换
格式:DOCX , 页数:25 ,大小:68.30KB ,
资源ID:22635650      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/22635650.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(华容道小游戏Word下载.docx)为本站会员(b****7)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

华容道小游戏Word下载.docx

1、% *See GUI Options on GUIDEs Tools menu. Choose GUI allows only one% instance to run (singleton).% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help untitled% Last Modified by GUIDE v2.5 18-Jul-2018 23:26:39% Begin initialization code - DO NOT EDITgui_Singleton

2、 = 1;gui_State = struct(gui_Name, mfilename, . gui_Singleton, gui_Singleton, .gui_OpeningFcn, untitled_OpeningFcn, .gui_OutputFcn, untitled_OutputFcn, .gui_LayoutFcn, , .gui_Callback, );if nargin & ischar(varargin1) gui_State.gui_Callback = str2func(varargin1);endif nargout varargout1:nargout = gui_

3、mainfcn(gui_State, varargin:);else gui_mainfcn(gui_State, varargin:% End initialization code - DO NOT EDIT% - Executes just before untitled is made visible.function untitled_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure%

4、 eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to untitled (see VARARGIN)% Choose default command line output for untitledhandles.output = hObject;% Update handles structureguidata(hObject

5、, handles);% UIWAIT makes untitled wait for user response (see UIRESUME)% uiwait(handles.figure1);% - Outputs from this function are returned to the command line.function varargout = untitled_OutputFcn(hObject, eventdata, handles)% varargout cell array for returning output args (see VARARGOUT);% Get

6、 default command line output from handles structurevarargout1 = handles.output;% - Executes on button press in pushbutton1.function pushbutton1_Callback(hObject, eventdata, handles) global A; A = 2 1 1 3; 2 1 1 3; 4 6 6 5; 4 7 7 5; 7 0 0 7;clahold on%在1的位置上写上曹操I J = find(A=1);x1 = min(J)-1;x2 = max(

7、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);ytext(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的位置上写上

8、赵云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);for i = 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+y

9、2),卒% 画背景line(0 4,0 0,colorblinewidth,4)line(0 4,5 5,line(0 0,0 5,line(4 4,0 5,4 line(0 4,i i,linestyle-3 line(i i,0 5,axis equalaxis(0 4 0 5)axis offfunction drawrect(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)% hObject handle to pushbutton1 (see GCBO)%

10、 - Executes on mouse press over axes background.function axes1_ButtonDownFcn(hObject, eventdata, handles)% hObject handle to axes1 (see GCBO)% - Executes during object creation, after setting all properties.function axes1_CreateFcn(hObject, eventdata, handles)% handles empty - handles not created un

11、til after all CreateFcns called% Hint: place code in OpeningFcn to populate axes1% - Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles)step_number=0; global A while 1 str=num2str(step_number),步; set(handles.edit2,string,str);if A(5,2)=1&A(5,3)=1ch = me

12、nu(曹操成功逃出华容道!如果要继续玩,按“是”,否则按“否”是否); switch ch case 1 untitled case 2 return end xpos,ypos = ginput(1); col = ceil(xpos); row = 5-ceil(ypos)+1; juese = A(row,col); switch juese case 1%点击了曹操 I,J = find(A=1); rm = max(I); rn = min(I); lm = max(J); ln = min(J); %判断是否能向左移 if ln1&A(rn,rm,ln-1)=0;0 A(rn,rm

13、,ln-1)=1;1; A(rn,rm,lm)=0;0; drawmap(A) step_number=step_number+1; %判断是否能向右移 if lm(A(rn-1,ln,lm)=0,0) A(rn-1,ln,lm)=1,1; A(rn+1,ln,lm)=0,0; %判断是否能向上移 if rm5&A(rm+1,ln,lm)=0,0 A(rm+1,ln,lm)=1,1; A(rm-1,ln,lm)=0,0;case 2% 点击了黄忠 I,J = find(A=2); A(rn,rm,ln-1)=2;2; A(rn,rm,lm+1)=2;A(rn-1,ln)=0A(rm+1,ln)

14、=0%如果又能上移又能下移,则要点击的部位 ch = menu(请选择移到的方向:上下 case 1%上移 A(rn-1,ln) = 2; A(rn+1,ln) = 0; case 2%下移 A(rm+1,ln) = 2; A(rm-1,ln) = 0; else%只能上移 elseif rmA(rm+1,ln)=0 case 3%张飞 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; case 4%马超 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