华容道小游戏
基于GUI界面的华容道小游戏(横刀立马)效果图如下:
A
忠
*
张
飞
马
关
羽
赵
超
卒
卒
云
卒
卒
实现5x4方格界面,初始化为华容道经典横刀立马局势 (如下图)。人物用数字来表示,
0代表空方格,1代表曹操,2代表黄忠,3代表张飞,4代表马超,5代表赵云,6代表 关羽,7代表小兵。曹操占4个方格,黄忠、张飞、马超、赵云、关羽分别占2个方格, 小兵占1个方格。
1、 游戏用鼠标玩,点击人物的任一方格后,该人物被选中,随后点击空方格,如果可以移 动,则选中的人物移动到方格处。
2、 游戏的目标是曹操从最下面一行的中间走出,就算成功。
3、 游戏能够显示已完成步数。
function varargout = untitled(varargin)
% UNTITLED MATLAB code for
% UNTITLED, by itself, creates a new UNTITLED or raises the existing
% singleton*.
%
% H = UNTITLED returns the handle to a new UNTITLED or the handle to
% the existing singleton*.
%
% UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in with the given input arguments.
%
% UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's 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 18-Jul-2018 23:26:39
% Begin initialization code - DO NOT EDIT
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',[]);
if nargin && ischar(varargin{1})
= str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before untitled is made visible.
function untitled_OpeningFcn(hObject, eventd
华容道小游戏 来自淘豆网www.taodocs.com转载请标明出处.