Code Monkey home page Code Monkey logo

3d-snake's Introduction

3D贪吃蛇小游戏

哈工大2024春《图形学与虚拟现实》课程大作业,使用Python和Pygame开发

Image 1 Image 2 Image 3

文件结构

  • main.py:主程序文件,负责游戏的初始化和主循环
  • snake.py:定义贪吃蛇类,包含贪吃蛇的移动、增长和碰撞检测等功能
  • food.py:定义食物类,包含食物的位置和重生功能
  • environment.py:包含绘制平面和立方体的函数,负责游戏环境的绘制
  • utils.py:包括游戏菜单在内的功能函数

依赖安装

在运行游戏之前,请确保已安装以下依赖:

pip install pygame PyOpenGL numpy

运行游戏

使用以下命令行运行游戏:

python main.py

游戏控制

注意:如果按键失效,请尝试将输入法切换至英文

命令 按键
开始游戏 S
重新游戏 R
退出游戏 Q
暂停 / 继续游戏 P
逆时针旋转 Left
顺时针旋转 Right
Roll left Left
Roll right Right

TODO

  • 添加环境光照
  • 为平面添加纹理
  • 修复立方体bug:调整立方体6个面的排序
  • 添加边界
  • 为蛇添加纹理
  • 添加主界面、暂停、开始
  • 食物旋转
    • 修复食物旋转bug
  • 增加蛇的间隔
    • 修复增加间隔后的闪烁bug
  • 旋转光照
  • 摄像机视角控制

3d-snake's People

Contributors

zrc0622 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.