基于matlab的超级玛丽游戏,【源码】小游戏:超级玛丽MATLAB版

b5534e7fbfe049c82c07b91a30fb2d5c.png

Super Mario Bros. Demo for MATLAB

Mingjing Zhang @ Simon Fraser University

What it is

This is a short demo of World 1-1 of Super Mario Bros. The demo emulates the behaviour of the original NES version as precise as my time and energy allow.

There are no enemies/coins/power-ups. The bricks are not interactive.

The flagpole and castle at the end of the stage are missing. The demo terminates when Mario moves out of the stage on the right.

There is background music which can be turned on before the game starts.

*The image you see up there is an ACTUAL screenshot of this demo.

Installation

Regular Version:

Put stl_mario_main.m and two .mat files under the same folder.

Run stl_mario_main.m

App Version:

Just like any other MATLAB app

Control

A/D - Left/Right

J - Sprint

K - Jump

How to Quit

Walk to the end of the stage, or;

Close the figure window

WARNING: The window should shut down itself upon error. If it doesn’t, please type ‘delete(gcf)’ in the command window to manually kill the figure window.

Enjoy!

完整源码下载地址:

http://page2.dfpan.com/fs/9l9c6jb2b281e289169/

更多精彩文章请关注微信号:

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
贪吃蛇游戏是一款经典的休闲游戏,很多人喜欢玩。最近,我用Matlab编程实现了一个贪吃蛇游戏源码程序,可以在Matlab界面下进行游戏。以下是一些关键的编程实现细节: 首先,我使用Matlab的图形用户界面(GUI)设计工具创建了一个游戏窗口,并添加了必要的组件,例如开始按钮、得分标签和重新开始按钮等。当点击开始按钮时,游戏开始,此时的主要任务是控制蛇移动。为了实现控制蛇的移动,我使用了Matlab的定时器功能,利用定时器来触发蛇的每个步骤。定时器的周期与蛇的移动速度相关。 接下来,考虑蛇的移动。为了使贪吃蛇行动灵活,我使用了一个链表来表示蛇的身体。链表中每个元素代表蛇的一个节点,包含该节点的位置和指向下一个节点的指针。当蛇移动时,只需修改链表中每个节点的位置即可。 在蛇移动过程中,需要检测是否碰到墙壁或者自身。当蛇与墙壁或自身相撞时,游戏结束。此时,我通过弹出对话框来提示游戏结束,并提供重新开始按钮为用户提供新一轮游戏的机会。 最后,还需要解决食物的生成与吃掉操作。食物可以随机生成,我使用了Matlab的随机数生成函数来实现。当蛇头移动到食物所在位置时,可以将食物删除,并将蛇尾后添加一个新的节点,表示蛇的身体增长。同时,加上食物的得分。 总体来说,编写这个贪吃蛇游戏源码程序是一项有趣且有挑战性的任务。它还提高了Matlab编程的技能和任意编程语言的编程能力。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值