资源描述:
《用matlab编写的俄罗斯方块小游戏》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
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',... 'Menubar','none','DoubleBuffer','on'
2、,'Resize','off','visible','on',... 'KeyPressFcn','RussiaBlock(''KeyPress_Callback'',gcbo)',... 'HelpFcn','helpdlg(''帮不了你--!'',''不好意思'')',... 'CloseRequestFcn','RussiaBlock(''CloseFigure_Callback'',gcbo)'); generate_FigureContent(FigureHandle); init_FigureContent(FigureHandle); s
3、et(FigureHandle,'Visible','on'); elseifischar(varargin{1}) feval(varargin{:}); end%-------------------------------------------------------------------------functiongenerate_FigureContent(FigureHandle)TabSpace=30;BlockWidth=20;BlockHeight=20;FigureWidth=BlockWidth*(12+1)+TabSpace*7;
4、FigureHeight=500;set(FigureHandle,'Position',[00FigureWidthFigureHeight]);movegui(FigureHandle,'center');%创建菜单BeginMenu=uimenu(FigureHandle,'Label','开始');StartMenu=uimenu(BeginMenu,'Label','开始新游戏','Accelerator','N',... 'Callback','RussiaBlock(''StartNewGame_Callback'',gcbo)');SaveMenu=uim
5、enu(BeginMenu,'Label','保存','Accelerator','S','Enable','off',... 'Separator','on','Cal','RussiaBlock(''SaveGame_Callback'',gcbo)');LoadMenu=uimenu(BeginMenu,'Label','读取','Accelerator','L','Enable','off',... 'Cal','RussiaBlock(''LoadGame_Callback'',gcbo)');QuitMenu=uimenu(BeginMenu,'Label',
6、'退出','Accelerator','Q','Separator','on','Cal','close(gcf)');OperationMenu=uimenu(FigureHandle,'Label','功能');BoardConfigMenu=uimenu(OperationMenu,'label','键盘设置','Enable','off',... 'Cal','RussiaBlock(''BoardConfig_Callback'',gcbo)');FigureConfigMenu=uimenu(OperationMenu,'label','界面设置','Enab
7、le','off',... 'Cal','RussiaBlock(''FigureConfig_Callback'',gcbo)');HighScoreMenu=uimenu(OperationMenu,'label','最高记录','Separator','on',... 'Cal','RussiaBlock(''HighScore_Callback'',gcbo)','Enable','off');GameLevelMenu=uimenu(OperationMenu,'Label','游戏难度',... 'Cal','Ru