小球消除方块游戏 by Kiro

iaun 06f9adcc98 Adjusting the difficulty hace 1 mes
src 06f9adcc98 Adjusting the difficulty hace 1 mes
tests 09dfddc1bc first commit hace 1 mes
.gitignore b6151dbfa8 remove .vscode hace 1 mes
DIN1451.ttf 09dfddc1bc first commit hace 1 mes
README.md 09dfddc1bc first commit hace 1 mes
color.txt 09dfddc1bc first commit hace 1 mes
index.html 09dfddc1bc first commit hace 1 mes
package-lock.json 09dfddc1bc first commit hace 1 mes
package.json 09dfddc1bc first commit hace 1 mes
style.css 09dfddc1bc first commit hace 1 mes
vitest.config.js 09dfddc1bc first commit hace 1 mes

README.md

小球消除方块

一款基于 Canvas 的弹球消方块小游戏,支持经典模式和增强模式。

环境要求

  • Node.js >= 18

安装依赖

npm install

调试(本地开发)

项目使用 ES Modules,需要通过 HTTP 服务器运行。推荐使用 npx serve

npx serve .

浏览器打开 http://localhost:3000 即可。

也可以使用任意静态服务器,如 VS Code 的 Live Server 插件,或 Python:

python -m http.server 8080

测试

npm test

使用 Vitest + jsdom 运行 170 个单元测试和属性测试。

打包(生产构建)

安装 Vite 后可一键打包:

npx vite build

产物输出到 dist/ 目录,可直接部署到任意静态托管服务。

如需自定义打包配置,创建 vite.config.js 并参考 Vite 文档

项目结构

├── index.html          # 入口页面
├── style.css           # 样式
├── DIN1451.ttf         # 数字字体
├── src/
│   ├── main.js         # 入口脚本
│   ├── Game.js         # 游戏主控
│   ├── constants.js    # 常量配置
│   ├── entities/       # 实体(Ball, Block, Item)
│   ├── systems/        # 系统(Renderer, Physics, BoardManager, GuideLine, InputHandler)
│   ├── ui/             # UI 组件(ModeSelector)
│   └── utils/          # 工具函数(color)
├── tests/              # 测试文件
└── game.js             # 原始参考实现