Code Monkey home page Code Monkey logo

snack-game's Introduction

Snack-Game

一个由typescript写的贪吃蛇简单小游戏

1.首先进行项目搭建,将webpack和TS的相关依赖下载安装好

2.然后进行项目创建,将所需要的主界面搭建好,包括边界,蛇,食物,记分牌等css样式

3.开始进入到每个类的具体编写,除了基本属性还有可能会用到的方法

食物(Food): 每次被吃掉后会生成随机定位改变食物的位置

记分牌(scorePanel): 蛇每吃掉一个食物分数会加1,每增加一个分数段会加一个等级,等级有上线且等级和分数段可修改

蛇(snack):蛇每吃一个食物会增加一节,且会和蛇头移动,蛇头不能触碰到自己的身子,蛇不能调头移动

4.编写键盘事件,可以控制蛇的运行情况

通过键盘的上下左右移动,可以改变蛇的行动方向,当蛇碰到墙壁时要结束游戏并停止运行,

5.最后编译运行,调试结果。

image

snack-game's People

Contributors

zhuang-57 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.