Files

78 lines
2.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Neon Arcade · 我的游戏合集首页
一个霓虹风格的**网页小游戏合集首页**。单文件、零依赖,每张卡片都带**实时预览动画**(不是截图,是真的在跑的小引擎)。
## 现在收录
| 游戏 | 类型 | 预览动画 |
| --- | --- | --- |
| [霓虹贪吃蛇](https://gitea.compute-thinking.cn/class04f27/neon-snake) | 街机 | 自动寻路的贪吃蛇(贪心 + 洪水填充算空间) |
| [霓虹俄罗斯方块](https://gitea.compute-thinking.cn/class04f27/neon-tetris) | 益智 | 自动堆叠、消行闪白的俄罗斯方块 |
## 特点
- **卡片墙自动生成**:所有卡片由 JS 里的 `GAMES` 数组渲染,加游戏只需要加一项数据,不用碰 HTML
- **实时预览**:每张卡片里跑一个迷你游戏引擎,不是录屏也不是图片
- **省电**:用 `IntersectionObserver` 检测卡片是否可见,划出屏幕就停掉动画;系统开了「减少动态效果」时只画一张静态画面
- **响应式**:`auto-fill` 网格,手机单列、桌面两列自适应
- **零依赖**:没有框架、没有 CDN、没有图片资源,一个 `index.html`
## 怎么加一个新游戏
编辑 `index.html` 里的 `GAMES` 数组,加一项:
```js
{
id: 'neon-breakout',
title: '霓虹打砖块',
en: 'NEON BREAKOUT',
tagline: 'ARCADE / 街机',
accent: '#ffd54a', // 卡片主色,徽章/标签/按钮/描边都跟着变
version: 'v1.0.0',
desc: '一句话介绍玩法。',
tags: ['Canvas 2D', '关卡设计'],
keys: '← → 移动挡板 · 空格 发球',
demo: 'snake', // 复用某个预览动画(或在 DEMOS 里加新的)
repo: 'https://gitea.compute-thinking.cn/class04f27/neon-breakout'
}
```
卡片里的「下载 index.html」链接会自动拼成 `仓库地址 + /raw/branch/main/index.html`,所以只要新游戏也是根目录下的 `index.html`,就不用改别的地方。
想给新游戏单独做一个预览动画,就在 `DEMOS` 里注册一个函数:
```js
const DEMOS = { snake: snakeDemo, tetris: tetrisDemo, breakout: breakoutDemo };
```
## 运行
直接双击 `index.html`,或者:
```bash
python3 -m http.server 8000
# 打开 http://localhost:8000
```
## 部署成在线游戏厅
把仓库根目录当静态站点根目录发布即可:
- **Gitea Pages**:仓库 → 设置 → Pages,源选 `main` 分支根目录
- **GitHub Pages**:Settings → Pages → Source 选 `main` / `root`
- **任意静态托管**:把 `index.html` 丢上去就行
部署之后,可以把卡片里的「打开仓库」按钮换成各游戏自己的在线地址,点进去直接开玩。
## 文件
```
.
├── index.html # 合集首页:样式 + 卡片渲染 + 两个预览动画引擎
└── README.md
```
## License
MIT