Coder Social home page Coder Social logo

pygame-snake's Introduction

第一步

游戏基本框架:初始化,加载资源,主循环,退出事件

实现游戏流程:开始,游戏,失败

第二步

创建蛇身精灵

绘制蛇身

更新

创建小蛇类(继承自group)

小蛇的初始化

析构

第三步

控制小蛇的运动

只有在上下运动时才能向左/右,左右运动时才能向上/下

KEY_DIRECTION

SetDirection()

ChangeDirection()

检测是否发生碰撞

CollideBox()

CollideSelf()

游戏失败提示

screen.blit(fail_img, (0, 0)) # 状态改变时运行一次即可

第四步

随机产生食物

食物不能在蛇身上,也不能在现有食物上

食物闪烁效果

吃到食物

碰撞检测

消失并再次产生食物

小蛇增长

在尾部添加蛇身

速度提升

第五步

计分功能

添加音效

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.