GithubHelp home page GithubHelp logo

snake's Introduction

十行代码挑战赛

所选题目:可交互的贪吃蛇游戏

代码介绍

代码使用 Matlab 完成了一个三维贪吃蛇的游戏,玩家可以通过键盘上的方向键控制蛇的移动,蛇吃到食物后会变长,当蛇碰到自己的身体时游戏结束。

  • 谁说 Matlab 只能做科学计算?我反手就搞个贪吃蛇出来!

得益于 Matlab 简单的三维画图函数 scatter3,基于 Matlab 制作出一个三维的空间并不难。不过由于 Matlab 缺少像 Pygame 一样可以读取键盘的库,所以需要将.m 函数放入 Matlab 的终端上面(也就是一开始下载 Matlab 时候的默认排列方式)不然需要一直 alt+tab 来回切屏

由于 3D 空间,控制方向键也从 4 个增加为 6 个了,采用小键盘的数字 4 6 8 2 分别作为 X,Y 轴的移动(8 和 6 为正向),控制 Z 轴的为 w 和 s 键。同时为了方便瞄准,视角会不断转动。(如果视角固定,几乎瞄准不了果子)

自行测试的运行环境

MATLAB 打开.m 函数即可运行。若要终止代码,请摁 x 或者 ctrl+c

使用的操作系统

win11

使用的编程语言版本

MATLAB R2022b

自定义的其他环境变量

snake's People

Contributors

wanghaochen1 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.