Giter VIP home page Giter VIP logo

plane-war's Introduction

飞机大战 Special Edition

Introduction

将micro-bit开发板作为游戏手柄,操控一个简单的飞机大战网页游戏(基于pixi.js开发)

技术细节:

  1. 操控实现:由于默认只能通过运行在开发板上的python程序读取和处理输入信息,为了实现对游戏的操控,利用pyserial库进行串口通讯读取按键信息,再使用相应的库在电脑端模拟键盘按键,起到将控制信息传给浏览器的效果。
  2. 反向通讯:为了将游戏中的状态实时更新到开发板上,我采用了一套极其暴力的解决方案。首先使用fastapi搭建一个简易的后端,用于存储和维护游戏状态;而网页游戏js代码中通过发起api请求的方式改变后端状态数据;最后在python端获取后端状态信息,利用串口通信将信息传递给开发板。

TechStack

游戏搭建:pixi.js

服务端搭建:fastapi

串口通信:pyserial

Demo Video

bilibili chbpku

Requirements

fastapi==0.96.0
pykeyboard==0.1.5
pyserial==3.5
PyUserInput==0.1.10
Requests==2.31.0

Usage

in ./microbit

uvicorn main:app
python server.py

client.py为在开发板上运行的代码

in ./game

http-server

或其他方式启动静态资源服务器

plane-war's People

Contributors

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