matlab编写的迷宫小游戏(6页).doc
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《matlab编写的迷宫小游戏(6页).doc》由会员分享,可在线阅读,更多相关《matlab编写的迷宫小游戏(6页).doc(6页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、-matlab编写的迷宫小游戏-第 6 页function mazerow = 20;col = 39;rand(state,sum(100*clock)cc,rr = meshgrid(1:col,1:row);state = reshape(1:row*col,row,col);id = reshape(1:row*col,row,col);ptr_left = zeros(size(id);ptr_up = zeros(size(id);ptr_right = zeros(size(id);ptr_down = zeros(size(id);ptr_left(:,2:size(id,2)
2、 = id(:,1:size(id,2)-1);ptr_up(2:size(id,1),:) = id(1:size(id,1)-1,:);ptr_right(:,1:size(id,2)-1) = id(:,2:size(id,2);ptr_down(1:size(id,1)-1,:) = id(2:size(id,1),:);the_maze = cat(2,reshape(id,row*col,1),reshape(rr,row*col,1),reshape(cc,row*col,1),reshape(state,row*col,1),. reshape(ptr_left,row*col
3、,1),reshape(ptr_up,row*col,1),reshape(ptr_right,row*col,1),reshape(ptr_down,row*col,1) );the_maze = sortrows(the_maze);id = the_maze(:,1);rr = the_maze(:,2);cc = the_maze(:,3);state = the_maze(:,4);ptr_left = the_maze(:,5);ptr_up = the_maze(:,6);ptr_right = the_maze(:,7);ptr_down = the_maze(:,8);cle
4、ar the_maze;state, ptr_left, ptr_up, ptr_right, ptr_down=. make_pattern(row,col,rr, cc, state, ptr_left, ptr_up, ptr_right, ptr_down);f = figure(Name,迷宫,. %显示图形窗口的标题 Numbertitle,off,. %标题栏中是否显示Figure No. n,其中n为图形窗口的编号 Menubar,none,. %转换图形窗口菜单条的“关” Color,white,. DoubleBuffer,on,. outerposition,get(0,
5、ScreenSize),. Colormap,.1 .71 0;.3 .4 .4;0 0 0;1 1 0,. CloseRequestFcn,close_window,. KeyPressFcn,move_spot);%建菜单gameMenu = uimenu(f,Label,游戏);uimenu(gameMenu,Label,新游戏,Accelerator,N,Callback,new_game);uimenu(gameMenu,Label,退出,Accelerator,Q,Separator,on,Callback,close_window);show_maze(row, col, rr,
6、 cc, ptr_left, ptr_up, ptr_right, ptr_down,f);% 开始cursor_pos = 1,1;current_id = 1;text(cursor_pos(1),cursor_pos(2),diamondsuit,HorizontalAlignment,Center,color,r);%计时timing = 1;start_time = clock; %按下键盘时触发 function move_spot(src,evnt)%获取方向建 % 记录过程 key = double(get(gcbf,Currentcharacter); if (ischar(
7、key)|isscalar(key) return; end if all(cursor_pos = col,row) key = double(get(gcbf,Currentcharacter); switch key case 28 % left if ptr_left(current_id) 0 % check for legal move current_id =- ptr_left(current_id); text(cursor_pos(1),cursor_pos(2),diamondsuit,HorizontalAlignment,Center,color,.8,.8,.8);
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- matlab 编写 迷宫 小游戏
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内