资源描述:
《用matlab编写的俄罗斯方块小游戏.doc》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、用matlab编写的俄罗斯方块小游戏·functionRussiaBlock(varargin)ifnargin==0 OldHandle=findobj('Type','figure','Tag','RussiaBlock'); ifishandle(OldHandle) delete(OldHandle); end FigureHandle=figure('Name','俄罗斯方块MATLAB版','Tag','RussiaBlock','NumberTitle','off',...
2、'Menubar','none','DoubleBuffer','on','Resize','off','visible','on',... 'KeyPressFcn','RussiaBlock(''KeyPress_Callback'',gcbo)',... 'HelpFcn','helpdlg(''帮不了你--!'',''不好意思'')',... 'CloseRequestFcn','RussiaBlock(''CloseFigure_Callback'',gcbo)'); generat
3、e_FigureContent(FigureHandle); init_FigureContent(FigureHandle); set(FigureHandle,'Visible','on'); elseifischar(varargin{1}) feval(varargin{:}); end%-------------------------------------------------------------------------functiongenerate_F
4、igureContent(FigureHandle)TabSpace=30;BlockWidth=20;BlockHeight=20;FigureWidth=BlockWidth*(12+1)+TabSpace*7;FigureHeight=500;set(FigureHandle,'Position',[00FigureWidthFigureHeight]);movegui(FigureHandle,'center');%创建菜单BeginMenu=uimenu(FigureHandle,'Labe
5、l','开始');StartMenu=uimenu(BeginMenu,'Label','开始新游戏','Accelerator','N',... 'Callback','RussiaBlock(''StartNewGame_Callback'',gcbo)');SaveMenu=uimenu(BeginMenu,'Label','保存','Accelerator','S','Enable','off',... 'Separator','on','Cal','RussiaBlock(''SaveGam
6、e_Callback'',gcbo)');LoadMenu=uimenu(BeginMenu,'Label','读取','Accelerator','L','Enable','off',... 'Cal','RussiaBlock(''LoadGame_Callback'',gcbo)');QuitMenu=uimenu(BeginMenu,'Label','退出','Accelerator','Q','Separator','on','Cal','close(gcf)');OperationMenu
7、=uimenu(FigureHandle,'Label','功能');BoardConfigMenu=uimenu(OperationMenu,'label','键盘设置','Enable','off',... 'Cal','RussiaBlock(''BoardConfig_Callback'',gcbo)');FigureConfigMenu=uimenu(OperationMenu,'label','界面设置','Enable','off',... 'Cal','RussiaBlock(''Fi
8、gureConfig_Callback'',gcbo)');HighScoreMenu=uimenu(OperationMenu,'label','最高记录','Separator','on',... 'Cal','RussiaBlock(''HighScore_Callback'',gcbo)','Enable','off');GameLevelMenu=uimenu(OperationMenu,'Label','游戏难度',... 'Cal','Ru