完成六区域银河城战役与16帧美术资源

This commit is contained in:
2026-07-16 15:42:39 +08:00
parent 42080fb6b0
commit 170f0a2ed5
114 changed files with 2109 additions and 11 deletions
+12
View File
@@ -0,0 +1,12 @@
.tmp/
.DS_Store
Thumbs.db
__pycache__/
*.pyc
# AI 绿幕原图和透明处理中间稿;最终运行图集保留在仓库中。
assets/*-chroma.png
assets/*-alpha.png
# 本地分析输出。
assets/*-analysis.png
+37
View File
@@ -0,0 +1,37 @@
# 《无声回廊》流程设计
## 核心体验
这是一款以朝比奈真冬为主角的单人银河城同人游戏。核心循环是“探索独立房间 → 节奏战斗 → 读取记忆 → 获取能力 → 回访旧路 → 打开新区域”。Canvas 只负责碰撞、镜头、雨幕和粒子;有辨识度的角色、怪物、Boss 与机关均使用固定格精灵图。
## 60–90 分钟首轮路线
1. **空白 SEKAI(0–8 分钟)**:安全教学房,学习移动、跳跃、普通攻击、PERFECT、冰弓与地图。
2. **沉水的记忆(8–20 分钟)**:首次分岔、歌词碎片与安全终端;清理记忆污染后连接第一组回声捷径。
3. **25 时回廊(20–34 分钟)**:取得静音冲刺,回访封音门;“无声指挥者”作为第一幕 Boss 检查战斗基础。
4. **无声剧场(34–46 分钟)**:更长的立体房间和第二组捷径,通过碎片与终端补全真冬的记忆。
5. **雨幕校园(46–58 分钟)**:四种扩展敌人组成混合遭遇;完成雨幕封锁战后,在镜面神龛取得二段跳。
6. **未写下的谱面(58–75 分钟)**:二段跳能力门、终局回环与黑化真冬 Boss;根据碎片收集度播放不同结束 CG。
静态内容模型估算首轮约 **71.8 分钟**。熟练玩家可跳过多数叙事与支线;全收集则需要回访两组捷径、点亮六盏记忆灯并收集十八枚歌词碎片。
## 能力与回环
- **静音冲刺**:穿过粉色封音门,打开早期区域的短路和碎片路线。
- **二段跳**:通过雨幕竞技场后在镜面神龛取得,越过终局谱面门并回收高处收藏。
- **冰弓**:消耗 25 点共鸣能量;PERFECT 补充能量,冰箭有概率冻结普通敌人。
- **冰剑蓄力**:不消耗能量,可移动蓄力,完成后释放小范围三点重击。
## 内容预算
- 20 个独立 2400px 房间、6 个主题区域、141 块可达平台。
- 46 个普通敌人,8 种敌人原型;第一幕 Boss 与终局 Boss 各一场。
- 18 枚歌词碎片、6 盏记忆灯、8 个终端、6 个长椅检查点、两组双向捷径。
- 怪物、Boss、机关和主要战斗动作均使用 16 帧图集;循环动作首尾闭合。
## 验收基线
- 所有平台链、碎片、终端、安全区与能力机关必须通过静态可达性检查。
- 敌人不得离开出生房间,地面单位不得自动走入坑洞,安全区会解除索敌和敌方弹体。
- 房间镜头严格裁切;跨越边界后才播放过场并加载下一房间。
- PC 与触控输入共享同一状态机;设置、地图、旅程记录、暂停和存档都不能遮挡后继续接收战斗输入。
+79
View File
@@ -0,0 +1,79 @@
# 无声回廊 / Silent Corridor
以朝比奈真冬为主角的私人非商业同人银河城游戏。作品把房间探索、能力回环和 PJSK 风格的节奏判定结合起来:玩家在破碎的 SEKAI 中寻找歌词碎片,通过 Nightcord 记忆终端拼回声音,最终面对“未写下的真冬”。
## 启动
在本目录运行:
```powershell
python -m http.server 5501 --bind 127.0.0.1
```
然后访问 <http://127.0.0.1:5501>。项目没有构建步骤或第三方运行依赖;建议使用 Chromium 系浏览器并通过真实点击开始游戏,以满足浏览器的音频播放策略。
## 操作
- `A / D` 或 `← / →`:移动
- `Space`、`W` 或 `↑`:跳跃;取得镜面回声后可二段跳
- `S / ↓ + 跳跃`:穿过薄平台
- 轻点 `J / X`:普通音符剑攻击;长按可移动蓄力,完成后松开释放冰剑重斩
- `L / C`:消耗 25 点能量凝聚冰弓并射出冰箭;冰箭概率冻结敌人
- `K / 左 Shift`:静音冲刺(探索取得)
- `S / ↓`:在长椅、安全终端、神龛或回声节点旁互动
- `M / Tab`:记忆地图
- `Q`:旅程记录、当前目标、能力和收集进度
- `Esc`:暂停 / 继续
移动端可在“设置 → 操作模式”选择自动识别、键鼠或触控。触控 HUD 包含连续速度摇杆、跳跃、攻击、冰弓、冲刺、互动,以及地图、旅程记录和暂停按钮;支持 Pointer Events 多点触控。
## 当前内容
- 20 个彼此隔离的 2400px 房间,6 个主题区域,总世界宽度 48000px
- 141 块经过可达性检查的平台、18 枚歌词碎片、6 盏记忆灯、8 个终端和 6 个长椅检查点
- 安全的新手同步室,依次引导移动、跳跃、练习攻击、PERFECT、冰弓和地图
- 静音冲刺与二段跳两项探索能力;两组双向回声捷径支持能力取得后的旧区回访
- 8 种普通敌人、46 个常规敌人,具有待机、巡逻、索敌、丢失目标、返巢、平台边缘检测和转向冷却
- 第一幕 Boss“无声指挥者”与终局 Boss“未写下的真冬”;终局 Boss 使用待机、施法、冲刺、崩解四组独立 16 帧动作
- 普攻、冰弓、移动蓄力与冰剑重斩均为 16 帧动作;怪物和主要交互物使用固定格 16 帧图集
- PERFECT / GREAT / MISS 节奏判定、连击、分数与能量循环;连续八次踩中节拍恢复生命
- 区域化雨幕、气泡、数据微粒、漂浮光球、房间过场、动态对话立绘和五张序幕/结局 CG
- 本地 BGM 区域交叉淡化和 22 类 SFX;BGM/SFX 音量、静音、全屏与操作模式均可保存
- 版本 7 长椅存档:检查点、能力、Boss、竞技场、碎片、记忆灯、地图探索、生命/能量上限、分数和游玩时间
- 地图、旅程记录、主菜单、设置、暂停、返回主菜单与 PC/移动端自适应 UI
按 [流程设计](GAME_DESIGN.md) 的首轮内容模型估算约 71.8 分钟;熟练直线通关会更短,全收集会更长。
## 主要美术资源
- `assets/mafuyu-idle.png`、`mafuyu-run.png`、`mafuyu-jump.png`:统一高马尾模型的基础动作
- `assets/mafuyu-attack-16.png`:16 帧普通音符剑
- `assets/mafuyu-ice-bow.png`:16 帧冰弓凝聚与释放
- `assets/mafuyu-ice-charge.png`、`mafuyu-ice-release.png`:16 帧移动蓄力循环与冰剑重斩
- `assets/mafuyu-bench-front-normalized.png`:正面坐下和休息动作
- `assets/mafuyu-portrait-normalized.png`:8 帧动态 Nightcord 对话立绘
- `assets/sekai-enemies-16.png`、`sekai-expansion-enemies-16.png`:八种怪物的 16 帧图集
- `assets/sekai-interactables-16.png`、`sekai-expansion-interactables-16.png`:长椅、终端、神龛、灯与捷径装置
- `assets/mafuyu-boss.png`、`mafuyu-final-boss-16.png`:第一幕与终局 Boss
- `assets/expansion-animation-preview.png`:扩展怪物、机关与终局 Boss 动作预览
- `assets/cg-prologue-*.png`、`assets/cg-ending-*.png`:三张序幕与两张结局 CG
生成提示、身份约束、绿幕处理和图集组装方式记录在 [AI 资产说明](assets/AI_ASSETS.md)。角色与原作相关权利归各自权利方所有,本项目仅作私人非商业练习。
## 静态校验
```powershell
node --check game.js
node tools/check_campaign.mjs
node tools/check_level.mjs
node tools/check_rooms.mjs
node tools/check_enemy_ai.mjs
node tools/check_gamefeel.mjs
node tools/check_ice_combat.mjs
node tools/check_demo.mjs
node tools/check_ui.mjs
python tools/check_animation_assets.py
node tools/benchmark_runtime.mjs
```
其中关卡检查覆盖平台跳跃链、18 枚碎片、捷径、终端、安全区、二段跳神龛和能力门;战役检查核对房间/区域/敌人/支线/存档/UI 与 60 分钟内容预算。浏览器实机手感、音频响度和移动端按钮舒适度仍建议由玩家最终确认。
View File
+115
View File
@@ -0,0 +1,115 @@
# AI 游戏资产记录
本页记录本项目通过 Codex 内置 `imagegen` 生成的游戏资产规格,便于后续继续生成时保持统一模型。
## 黑化真冬 Boss
- 最终文件:`mafuyu-boss.png`
- 绿幕原图:`mafuyu-boss-chroma.png`
- 身份参考:`mafuyu-model-reference.png`
- 布局:4 列 × 4 行,共 16 帧
- 动作:悬浮待机 4 帧、指挥/施法 4 帧、冲刺斩击 4 帧、受击与崩解 4 帧
- 最终提示规格:保留参考图的紫瞳、深紫高马尾、宫益坂风黑色开衫、灰色百褶裙、海员领和红领结;变化仅限疲惫冷淡表情、黑紫污染、洋红/青色音符故障、破裂白色面具碎片。严格侧视、面向左侧、同一人物比例、纯 `#00ff00` 绿幕、无文字和水印。
## SEKAI 怪物图集
- 四帧关键原画源:`sekai-enemies.png`;当前运行文件为后文记录的 `sekai-enemies-16.png`
- 绿幕原图:`sekai-enemies-chroma.png`
- 风格参考:`mafuyu-boss.png`
- 布局:4 列 × 4 行,共 16 帧
- 行 1:残响影兽,4 帧地面移动
- 行 2:水族馆微光,4 帧漂浮脉动
- 行 3:失真爬行体,4 帧伏地/跃击
- 行 4:信号哨兵,4 帧蓄力/射击
- 最终提示规格:统一黑紫阴影材质、青色与洋红数字音符故障、日系音乐手游式赛璐璐渲染和清晰轮廓;严格侧视、面向左侧、纯 `#00ff00` 绿幕、无人物、文字和水印。
透明版本使用 imagegen 技能自带的 `remove_chroma_key.py` 进行软遮罩、去绿边处理;游戏运行时仅在图片加载失败时使用 Canvas 几何兜底。
## 真冬远程音律投射(旧版,已停用)
- 旧版运行文件:`mafuyu-ranged.png`;当前运行时已由 16 帧冰弓动画替代
- 绿幕原图:`mafuyu-ranged-chroma.png`
- 身份参考:`mafuyu-model-reference.png`、`mafuyu-attack-chroma.png`
- 布局:4 列 × 2 行,共 8 帧
- 动作:蓄力 3 帧、向右释放 3 帧、音律残光与回到待机 2 帧
- 运行规格:完整动作 0.52 秒,弹体在第 4 帧附近生成;固定脚底基线,并使用逐帧人物锚点避免长投射特效导致模型横向跳动。
- 关键约束:保持紫色高马尾、黑色开衫校服、灰色百褶裙、红领结和侧视比例;青紫音符能量不能遮挡脸部;纯 `#00ff00` 绿幕,无文字、水印或相邻帧重叠。
## 序幕与结局 CG
- 序幕:`cg-prologue-nightcord.png`、`cg-prologue-arrival.png`、`cg-prologue-aquarium.png`
- 结局:`cg-ending-true.png`、`cg-ending-return.png`
- 身份参考:`mafuyu-model-reference.png`、`mafuyu-key-visual.png`
- 叙事顺序:25:00 雨夜断线 → 抵达空白 SEKAI → 水族馆记忆;结局根据是否收齐十枚歌词切换黎明抵达或回望未完成回廊。
- 画面规格:16:9 横向动画 CG,人物位于右侧,左侧保留对话与结局文字区域;图片内不生成文字,所有字幕由 HTML 界面绘制。
## 真冬交互与长椅休息动作
- 最终运行文件:`mafuyu-interactions-normalized.png`
- 修正后的透明源图:`mafuyu-interactions-v2.png`
- 修正后的绿幕源图:`mafuyu-interactions-v2-chroma.png`
- 初稿保留:`mafuyu-interactions.png`、`mafuyu-interactions-chroma.png`(初稿休息姿势为跪坐,未接入运行时)
- 身份参考:`mafuyu-model-reference.png`
- 布局:4 列 × 4 行,共 16 帧
- 动作:终端触碰 4 帧、坐下 4 帧、休息呼吸循环 8 帧;起身使用坐下动作反向播放
- 规范化:Game Studio `normalize_sprite_strip.py`,统一 256×256 帧位与底部中心锚点,再重组为 1024×1024 图集
- 关键约束:严格保持深紫色高马尾、紫瞳、黑色开衫、水手领、红领结、灰色百褶裙、黑色及膝袜和棕色皮鞋;始终面向画面右侧。坐姿要求大腿水平、膝盖约 90°、小腿垂直、双脚落地,禁止跪坐、正坐或蹲姿。
## 真冬正面长椅动作(当前版本)
- 最终运行文件:`mafuyu-bench-front-normalized.png`
- 透明生成源:`mafuyu-bench-front.png`
- 绿幕原图:`mafuyu-bench-front-chroma.png`
- 身份参考:`mafuyu-model-reference.png`、`mafuyu-interactions-normalized.png`
- 布局:4 列 × 3 行,共 12 帧;第 1 行为正面坐下 4 帧,第 2–3 行为正面休息 8 帧
- 规范化:按 Game Studio `sprite-pipeline` 流程一次性生成整条动作,再使用 `normalize_sprite_strip.py` 统一为 256×256 帧位与底部中心锚点
- 关键约束:全程正对镜头,身体中轴、头部大小和座面高度稳定;坐姿双膝朝前、小腿垂直、双脚平放,双手自然放在膝上;人物图层不包含长椅。
## SEKAI 交互实体图集
- 四帧关键原画源:`sekai-interactables.png`;当前运行文件为后文记录的 `sekai-interactables-16.png`
- 绿幕源图:`sekai-interactables-chroma.png`
- 布局:4 列 × 4 行,共 16 帧
- 第 1 行:Nightcord 记忆长椅,4 帧青紫波形灯带呼吸循环
- 第 2 行:共鸣水晶与破损底座,4 帧沉睡/苏醒能量循环
- 第 3 行:双向回声节点,4 帧青色浮环旋转循环
- 第 4 行:Nightcord 记忆终端,4 帧波形屏幕扫描循环
- 关键约束:日系音乐手游环境实体风格、黑紫/青色/洋红配色、严格侧视图、每行轮廓与尺寸稳定、纯 `#00ff00` 绿幕、无人物、文字、水印、投影和地面。
## 真冬动态对话立绘
- 最终运行文件:`mafuyu-portrait-normalized.png`
- 绿幕原图:`mafuyu-portrait-chroma.png`
- 预览:`mafuyu-portrait-preview.png`
- 身份参考:`mafuyu-model-reference.png`
- 布局:4 列 × 2 行,共 8 帧;第 1 行为呼吸、半眨眼和闭眼,第 2 行为三档口型与轻微表情变化
- 规范化:`tools/prepare_portrait_atlas.py` 按单元格去除绿幕、清理绿色溢色,再统一为 320×320 胸像帧位和固定肩线/眼线
- 关键约束:双手与前臂完全不入画,固定 3/4 机位、脸型、发束、肩宽和制服线条;只允许眼睛、嘴型与极轻微发梢摆动,避免逐帧重新生成造成的人物漂移和常见 AI 手部瑕疵。
以上新增素材均使用 Codex 内置 imagegen 模式生成,再通过本地绿幕移除与 Game Studio 精灵规范化流程接入项目。
## 冰系战斗动画(2026-07)
- `mafuyu-attack-16.png`:4×4 固定格、共 16 帧;普通音符剑从音符生成、短距离水平挥砍到收势。它与冰剑重斩分开整条生成,避免用光流在大幅人体姿势间制造双轮廓;绿幕源与透明中间文件分别为 `mafuyu-attack-16-chroma.png` 和 `mafuyu-attack-16-alpha.png`。
- `mafuyu-ice-bow.png`:4×4 固定格、共 16 帧;音符在双手凝聚、形成浅青冰弓、拉弦生成冰箭、释放并回收。角色严格沿用 `mafuyu-model-reference.png` 的高马尾、制服、脸型与侧视比例。
- `mafuyu-ice-charge.png`:4×4 固定格、共 16 帧;低位双手持冰剑的移动蓄力循环。生成图最下排存在贴边风险,因此运行图只使用前 12 个完整姿势,并按 `0…11 → 8 → 5 → 2 → 0` 重编排,使第 16 帧与第 1 帧同姿闭环。
- `mafuyu-ice-release.png`:4×4 固定格、共 16 帧;低位预备、举剑、水平冰霜重斩、短距离冰弧、跟随动作与收势。
- 绿幕源分别为 `mafuyu-ice-bow-chroma.png`、`mafuyu-ice-charge-chroma.png`、`mafuyu-ice-release-chroma.png`;`*-alpha.png` 是内置 imagegen 输出经 `remove_chroma_key.py` 去除纯色背景后的中间文件。
- 三套最终图均由 Codex 内置 imagegen 模式一次性生成完整 16 格,而非逐帧独立生成;提示词的共同约束为:同一角色、同一右朝向、同一比例与脚底基线、每格仅一个完整人物、人物与武器不得跨格、纯 `#00ff00` 背景、无文字/场景/阴影/水印。
- `tools/build_high_frame_atlases.py` 会统一加入安全边距、清理与主体断开的暗色残片、检查帧边缘 Alpha,并生成 `combat-animation-preview.png`。
## 16 帧环境实体与怪物循环
- `sekai-interactables-16.png`:保留原 AI 交互物外观,以每行 4 张关键原画进行双向光流形变,生成每种实体 16 个固定格中间帧;每个循环的最后一段回到第一张关键原画,避免首尾跳变。
- `sekai-enemies-16.png`:保留四类怪物的单张完整主体,以轻微位移、呼吸缩放和角度变化生成 16 帧单轮廓循环。怪物不再同时透明叠画两张差异较大的原画,因此第一关不会出现一帧中带有两个头部或肢体残片的情况。
- 运行时对以上两套 16 帧图集只绘制一个整数帧,不再做相邻帧 Alpha 交叉淡化。
## 战役扩展图集(2026-07)
- 生成模式:Codex 内置 `imagegen`,以既有真冬模型、黑紫/青色 SEKAI 配色和日系音乐手游赛璐璐渲染为统一视觉约束。
- `sekai-expansion-enemies-16.png`:面具游灵、节拍器守卫、雨声唱诗体、镜像猎犬四行,每行 16 个独立动作姿势。提示要求严格侧视、单帧单主体、固定脚底/身体中心、轮廓连续、无文字/水印/场景,并避免相邻格肢体串联。
- `mafuyu-final-boss-16.png`:未写下的真冬,待机、谱面施法、镜面冲刺、崩解四行,每行 16 帧。提示锁定紫瞳、深紫高马尾、黑色开衫校服、灰色百褶裙、红领结和冷淡神情,只允许黑紫污染、洋红/青色音符故障与白色面具碎片变化。
- `sekai-expansion-interactables-16.png`:雨幕记忆灯、Nightcord 电话亭终端、镜面神龛、谱面能力门各 16 帧闭环;由四张 AI 关键原画经双向光流补间并首尾闭合。
- `tools/build_expansion_atlases.py`:统一裁切、脚底/中心锚点、清除主体上方离散残片并打包运行图集;施法动作使用完整姿势回摆序列,避开生成源贴边的一行。
- `assets/expansion-animation-preview.png`:最终扩展图集抽帧预览,用于检查轮廓、单主体、锚点和动作一致性。
- 绿幕与透明中间稿命名为 `*-chroma.png` / `*-alpha.png`,本地保留用于再处理,但 Git 默认忽略;运行时只依赖上述最终图集。
+32
View File
@@ -0,0 +1,32 @@
# Audio Sources
## Music and two system sounds
Source: [Dark Sci-Fi Audio Pack](https://opengameart.org/content/dark-sci-fi-audio-pack) by SRG774.
License: CC0 1.0 Universal / Public Domain. Attribution is not required; this credit is retained for provenance.
- `bgm-empty.mp3` ← `Airy.mp3`
- `bgm-aquarium.mp3` ← `Sector.mp3`
- `bgm-corridor.mp3` ← `Pulse.mp3`
- `bgm-stage.mp3` ← `Urgent.mp3`
- `bgm-ending.mp3` ← `Transmission.mp3`
- `sfx-victory.mp3` ← `Victory.mp3`
五首 BGM 在不改变曲目内容的前提下使用 FFmpeg `loudnorm` 统一至约 -18 LUFS、峰值上限 -1.5 dB,解决原文件平均响度约 -40 dB 导致的不可闻问题。
## Gameplay and interface sounds
Sources: Kenney [Interface Sounds](https://kenney.nl/assets/interface-sounds), [Digital Audio](https://kenney.nl/assets/digital-audio), [RPG Audio](https://kenney.nl/assets/rpg-audio), and [Impact Sounds](https://kenney.nl/assets/impact-sounds).
License: Creative Commons CC0. The original Kenney license notice is preserved as `KENNEY_LICENSE.txt`.
Selected sounds were renamed by gameplay role: menu hover/confirm/back, transition, checkpoint, death, attack, hit, hurt, footsteps, jump, dash, collect, enemy shot, and boss cast.
## Attack sound audition library
`attack-candidates/` contains 18 optional CC0 attack sounds for local A/B comparison. The normal note-blade now uses the selected `layered-swish-phaser.ogg`; the previous file is retained as `sfx-attack-legacy.ogg`. Additional sources are [Swishes Sound Pack](https://lpc.opengameart.org/content/swishes-sound-pack) by artisticdude and [Magic Spell SFX](https://opengameart.org/content/magic-spell-sfx) by JaggedStone. Exact source-to-file mapping and edit notes are recorded in `attack-candidates/LICENSES.md` and `attack-candidates/README.md`.
## Ice combat sound set
`sfx-ice-bow-charge.ogg`, `sfx-ice-arrow.ogg`, `sfx-ice-charge.ogg`, `sfx-ice-heavy.ogg`, and `sfx-freeze.ogg` are short mono mixes built from the same CC0 Swishes, Magic Spell SFX, Kenney Digital Audio, and Kenney Impact Sounds sources. They were trimmed, faded, layered, and normalized for the ice bow, ice sword, arrow release, heavy slash, and freeze state. Rebuild details are in `tools/build_ice_combat_sfx.ps1`.
+20
View File
@@ -0,0 +1,20 @@
Interface Sounds (1.0)
Created/distributed by Kenney (www.kenney.nl)
Creation date: 11-02-2020
------------------------------
License: Creative Commons Zero (CC0)
http://creativecommons.org/publicdomain/zero/1.0/
This content is free to use in personal, educational and commercial projects.
Support us by crediting Kenney or www.kenney.nl (this is not mandatory).
------------------------------
Donate: http://support.kenney.nl
Patreon: http://patreon.com/kenney/
Follow on Twitter for updates:
http://twitter.com/KenneyNL
@@ -0,0 +1,27 @@
# Sources and licenses
All source sounds used in this candidate library are released under Creative Commons CC0 / public domain terms. Attribution is not required; these details are retained for provenance.
## Kenney
- [RPG Audio](https://www.kenney.nl/assets/rpg-audio): `knifeSlice.ogg`
- [Digital Audio](https://www.kenney.nl/assets/digital-audio): `phaserUp2.ogg`, `phaseJump2.ogg`, `laser3.ogg`
- License: CC0. Kenney's included license notice is preserved at `../KENNEY_LICENSE.txt`.
## Swishes Sound Pack
- Source: [Swishes Sound Pack](https://lpc.opengameart.org/content/swishes-sound-pack)
- Author: artisticdude
- Files used: `swish-1.wav`, `swish-2.wav`, `swish-3.wav`, `swish-4.wav`, `swish-7.wav`, `swish-8.wav`, `swish-9.wav`, `swish-12.wav`
- License: CC0
## Magic Spell SFX
- Source: [Magic Spell SFX](https://opengameart.org/content/magic-spell-sfx)
- Author: JaggedStone
- Files used: `magical_1.ogg`, `magical_2.ogg`, `magical_3.ogg`
- License: CC0
## Edits
The files in this directory are format conversions, loudness-normalized edits, short fades, or mixes of the CC0 inputs listed above. The layered candidates contain no additional source material.
+35
View File
@@ -0,0 +1,35 @@
# Attack sound candidate library
Open `index.html` through the project's local web server to compare every candidate against the current in-game attack sound.
```powershell
python -m http.server 5501 --bind 127.0.0.1
```
Then visit <http://127.0.0.1:5501/assets/audio/attack-candidates/>.
The current `assets/audio/sfx-attack.ogg` is the A reference. The ice-combat update selected `layered-swish-phaser.ogg` for the normal note-blade attack. The former Kenney RPG Audio `knifeSlice2.ogg` version is preserved as `assets/audio/sfx-attack-legacy.ogg`.
## Candidates
| Files | Count | Purpose | Source |
| --- | ---: | --- | --- |
| `physical-swish-*.ogg` | 8 | Fast wind and weapon movement | Swishes Sound Pack |
| `physical-knife-slice-alt.ogg` | 1 | Alternate physical slice | Kenney RPG Audio |
| `energy-*.ogg` | 6 | Digital, laser, and short magic accents | Kenney Digital Audio / Magic Spell SFX |
| `layered-*.ogg` | 3 | Physical attack plus a quieter energy layer | CC0 sources above |
All candidates are mono 48 kHz Ogg Vorbis files normalized near -18 LUFS, with a -2 dB true-peak target. The longer laser and magic sources are trimmed and faded for a short player attack.
## Replacing the current sound
Back up the current sound, then copy the selected file over it:
```powershell
Copy-Item -LiteralPath 'assets\audio\sfx-attack.ogg' -Destination 'assets\audio\sfx-attack.backup.ogg'
Copy-Item -LiteralPath 'assets\audio\attack-candidates\layered-swish-phaser.ogg' -Destination 'assets\audio\sfx-attack.ogg' -Force
```
Alternatively, point `SFX_TRACKS.attack` in `game.js` at a candidate file. Browser caching can preserve the previous sound during development; use a hard refresh after replacing it.
See `LICENSES.md` for source and license details. Rebuild the processed files with `tools/build_attack_candidates.ps1`.
Binary file not shown.
+254
View File
@@ -0,0 +1,254 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>朝比奈真冬 · 攻击音效 A/B 试听</title>
<style>
:root {
color-scheme: dark;
--ink: #f6f1ff;
--muted: #aca3bd;
--panel: rgba(23, 19, 35, .82);
--line: rgba(226, 209, 255, .14);
--violet: #b39aff;
--pink: #f3a6d5;
--cyan: #8ce0ef;
}
* { box-sizing: border-box; }
body {
margin: 0;
min-height: 100vh;
color: var(--ink);
font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
background:
radial-gradient(circle at 18% 8%, rgba(134, 100, 208, .19), transparent 35rem),
radial-gradient(circle at 88% 4%, rgba(77, 185, 207, .11), transparent 28rem),
linear-gradient(150deg, #0b0912, #171121 52%, #0c1018);
}
body::before {
content: "";
position: fixed;
inset: 0;
pointer-events: none;
opacity: .19;
background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
background-size: 36px 36px;
mask-image: linear-gradient(to bottom, black, transparent 80%);
}
main { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 56px 0 80px; }
.eyebrow { color: var(--pink); font-size: 12px; letter-spacing: .24em; text-transform: uppercase; }
h1 { margin: 10px 0 12px; font-size: clamp(30px, 5vw, 54px); font-weight: 650; letter-spacing: -.035em; }
.intro { max-width: 760px; margin: 0; color: var(--muted); line-height: 1.75; }
.toolbar {
position: sticky;
top: 12px;
z-index: 5;
display: grid;
grid-template-columns: 1fr auto auto;
gap: 12px;
align-items: center;
margin: 30px 0 34px;
padding: 14px;
border: 1px solid var(--line);
border-radius: 18px;
background: rgba(16, 13, 25, .88);
box-shadow: 0 16px 50px rgba(0,0,0,.3);
backdrop-filter: blur(16px);
}
.now { min-width: 0; }
.now small { display: block; margin-bottom: 3px; color: var(--muted); }
#nowName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button {
border: 1px solid var(--line);
border-radius: 12px;
padding: 10px 14px;
color: var(--ink);
font: inherit;
cursor: pointer;
background: rgba(255,255,255,.055);
transition: transform .12s ease, border-color .15s ease, background .15s ease;
}
button:hover { border-color: rgba(179,154,255,.62); background: rgba(179,154,255,.11); }
button:active { transform: translateY(1px) scale(.985); }
button.primary { color: #130d1c; border: 0; background: linear-gradient(135deg, var(--violet), var(--pink)); font-weight: 700; }
.settings {
display: flex;
gap: 18px;
align-items: center;
flex-wrap: wrap;
margin-bottom: 34px;
color: var(--muted);
font-size: 13px;
}
.settings label { display: flex; gap: 9px; align-items: center; }
input[type="range"] { accent-color: var(--violet); width: 150px; }
section { margin-top: 34px; }
.section-head { display: flex; gap: 14px; align-items: baseline; margin-bottom: 13px; }
h2 { margin: 0; font-size: 20px; font-weight: 620; }
.section-head span { color: var(--muted); font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.card {
position: relative;
min-height: 152px;
padding: 17px;
border: 1px solid var(--line);
border-radius: 17px;
background: var(--panel);
overflow: hidden;
transition: border-color .18s ease, transform .18s ease, background .18s ease;
}
.card:hover { transform: translateY(-2px); border-color: rgba(179,154,255,.36); }
.card.selected { border-color: var(--violet); background: rgba(47, 36, 69, .91); box-shadow: inset 0 0 0 1px rgba(179,154,255,.18); }
.card::after { content: ""; position: absolute; right: -32px; bottom: -42px; width: 110px; height: 110px; border-radius: 50%; background: var(--accent, var(--violet)); opacity: .08; filter: blur(2px); }
.card-top { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.card h3 { margin: 12px 0 7px; font-size: 17px; }
.card p { min-height: 37px; margin: 0 0 14px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.card-actions { display: flex; gap: 8px; }
.card-actions button { position: relative; z-index: 1; padding: 8px 11px; font-size: 12px; }
.physical { --accent: var(--pink); }
.energy { --accent: var(--cyan); }
.layered { --accent: var(--violet); }
.help { margin-top: 46px; padding: 20px; border: 1px solid var(--line); border-radius: 17px; color: var(--muted); background: rgba(10,9,16,.55); line-height: 1.7; }
.help strong { color: var(--ink); }
code { color: #e4d7ff; overflow-wrap: anywhere; }
#toast { position: fixed; left: 50%; bottom: 24px; z-index: 10; translate: -50% 12px; padding: 10px 15px; border-radius: 999px; color: #160e21; background: #eadfff; opacity: 0; pointer-events: none; transition: .2s ease; }
#toast.show { translate: -50% 0; opacity: 1; }
@media (max-width: 800px) { .grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 590px) {
main { width: min(100% - 22px, 1120px); padding-top: 32px; }
.toolbar { grid-template-columns: 1fr 1fr; }
.now { grid-column: 1 / -1; }
.toolbar button { width: 100%; }
.grid { grid-template-columns: 1fr; }
input[type="range"] { width: 122px; }
}
</style>
</head>
<body>
<main>
<div class="eyebrow">Silent Corridor · Sound Lab</div>
<h1>攻击音效 A/B 试听</h1>
<p class="intro">现有攻击音效作为 A 基准,不会被这个页面修改。先在卡片中选择一个候选 B,再用顶部按钮反复对比;建议戴耳机,同时尝试不同播放速度。</p>
<div class="toolbar">
<div class="now"><small>当前候选 B</small><div id="nowName">尚未选择</div></div>
<button id="playA">A · 当前音效</button>
<button id="playB" class="primary" disabled>B · 播放候选</button>
</div>
<div class="settings">
<label>音量 <input id="volume" type="range" min="0" max="1" step="0.05" value="0.75"><output id="volumeOut">75%</output></label>
<label>速度 <input id="rate" type="range" min="0.75" max="1.35" step="0.05" value="1"><output id="rateOut">1.00×</output></label>
<span>快捷键:A 播放原音效,B 播放候选,空格重播上一次</span>
</div>
<div id="groups"></div>
<div class="help">
<strong>选定后如何替换:</strong>先备份 <code>assets/audio/sfx-attack.ogg</code>,再把所选候选文件复制并改名为 <code>sfx-attack.ogg</code>。也可以只修改 <code>game.js</code> 中 <code>SFX_TRACKS.attack</code> 的路径。点击卡片里的“复制替换命令”可复制一条 PowerShell 命令;页面本身不会写入游戏文件。
</div>
</main>
<div id="toast" role="status"></div>
<script>
const groups = [
{ id: 'physical', title: '挥砍 / 风切', hint: '短促、实体感强,适合普通近战', items: [
['physical-swish-01.ogg', 'Swish 01', '极短挥动样本,适合轻攻击。'],
['physical-swish-02.ogg', 'Swish 02', '另一种极短风切,可用于更快的起手。'],
['physical-swish-03.ogg', 'Swish 03', '短挥动样本,轮廓相对完整。'],
['physical-swish-04.ogg', 'Swish 04', '紧凑风切,可尝试稍低播放速度。'],
['physical-swish-07.ogg', 'Swish 07', '较长的挥动尾音,动作存在感更明显。'],
['physical-swish-08.ogg', 'Swish 08', '轻量短尾,适合连续攻击。'],
['physical-swish-09.ogg', 'Swish 09', '中短风切,适合作为节拍音刃底层。'],
['physical-swish-12.ogg', 'Swish 12', '非常短促,可叠加命中特效音。'],
['physical-knife-slice-alt.ogg', 'Knife Slice Alt', 'Kenney 的另一条切割声,不是游戏当前文件。']
]},
{ id: 'energy', title: '能量 / 音符', hint: '更贴近 SEKAI 与节奏音刃的电子质感', items: [
['energy-phaser-rise.ogg', 'Phaser Rise', '短数字上升音,适合 PERFECT 攻击。'],
['energy-phase-snap.ogg', 'Phase Snap', '紧凑相位脉冲,起音较明确。'],
['energy-laser-short.ogg', 'Laser Short', '激光素材的短裁切版,尾部已淡出。'],
['energy-magic-01-short.ogg', 'Magic 01 Short', '魔法素材短版,可尝试 1.10× 速度。'],
['energy-magic-02-short.ogg', 'Magic 02 Short', '第二条魔法素材短版。'],
['energy-magic-03-short.ogg', 'Magic 03 Short', '第三条魔法素材短版。']
]},
{ id: 'layered', title: '混合版本', hint: '挥动声负责手感,电子或魔法层负责角色辨识度', items: [
['layered-swish-phaser.ogg', 'Swish + Phaser', '风切与数字上升音的双层版本。'],
['layered-swish-magic.ogg', 'Swish + Magic', '风切与短魔法尾音的双层版本。'],
['layered-knife-phase.ogg', 'Knife + Phase', '切割与相位脉冲结合,实体感更强。']
]}
];
const root = document.querySelector('#groups');
const audio = new Audio();
const volume = document.querySelector('#volume');
const rate = document.querySelector('#rate');
const playB = document.querySelector('#playB');
const nowName = document.querySelector('#nowName');
const toast = document.querySelector('#toast');
let selected = null;
let lastSource = null;
let toastTimer = 0;
function escapeShellSingle(value) { return value.replaceAll("'", "''"); }
function notify(message) {
toast.textContent = message;
toast.classList.add('show');
clearTimeout(toastTimer);
toastTimer = setTimeout(() => toast.classList.remove('show'), 1800);
}
function play(source, label) {
lastSource = { source, label };
audio.pause();
audio.src = source;
audio.currentTime = 0;
audio.volume = Number(volume.value);
audio.playbackRate = Number(rate.value);
audio.play().then(() => { nowName.textContent = `正在播放:${label}`; }).catch(() => notify('浏览器阻止了播放,请再点击一次'));
}
function select(item, title, card) {
selected = { source: item, title };
document.querySelectorAll('.card').forEach(node => node.classList.toggle('selected', node === card));
card.classList.add('selected');
nowName.textContent = title;
playB.disabled = false;
localStorage.setItem('attack-candidate', item);
}
async function copyCommand(file) {
const command = `Copy-Item -LiteralPath 'assets\\audio\\attack-candidates\\${escapeShellSingle(file)}' -Destination 'assets\\audio\\sfx-attack.ogg' -Force`;
try { await navigator.clipboard.writeText(command); notify('替换命令已复制'); }
catch { window.prompt('请手动复制:', command); }
}
groups.forEach(group => {
const section = document.createElement('section');
section.innerHTML = `<div class="section-head"><h2>${group.title}</h2><span>${group.hint}</span></div><div class="grid"></div>`;
const grid = section.querySelector('.grid');
group.items.forEach(([file, title, note], index) => {
const card = document.createElement('article');
card.className = `card ${group.id}`;
card.innerHTML = `<div class="card-top"><span>${group.id}</span><span class="duration">读取时长…</span></div><h3>${title}</h3><p>${note}</p><div class="card-actions"><button class="listen">选择并播放</button><button class="copy">复制替换命令</button></div>`;
const probe = new Audio(file);
probe.preload = 'metadata';
probe.addEventListener('loadedmetadata', () => card.querySelector('.duration').textContent = `${probe.duration.toFixed(2)} s`);
card.querySelector('.listen').addEventListener('click', () => { select(file, title, card); play(file, title); });
card.querySelector('.copy').addEventListener('click', () => copyCommand(file));
grid.append(card);
if (localStorage.getItem('attack-candidate') === file) select(file, title, card);
});
root.append(section);
});
document.querySelector('#playA').addEventListener('click', () => play('../sfx-attack.ogg', 'A · 游戏当前音效'));
playB.addEventListener('click', () => selected && play(selected.source, `B · ${selected.title}`));
volume.addEventListener('input', () => { audio.volume = Number(volume.value); document.querySelector('#volumeOut').value = `${Math.round(volume.value * 100)}%`; });
rate.addEventListener('input', () => { audio.playbackRate = Number(rate.value); document.querySelector('#rateOut').value = `${Number(rate.value).toFixed(2)}×`; });
document.addEventListener('keydown', event => {
if (event.target.matches('input, button')) return;
if (event.code === 'KeyA') play('../sfx-attack.ogg', 'A · 游戏当前音效');
if (event.code === 'KeyB' && selected) play(selected.source, `B · ${selected.title}`);
if (event.code === 'Space' && lastSource) { event.preventDefault(); play(lastSource.source, lastSource.label); }
});
</script>
</body>
</html>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 946 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 672 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 787 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 856 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 774 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 579 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 946 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 616 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 667 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 718 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 984 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 902 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1006 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

+14 -11
View File
@@ -178,9 +178,9 @@
{x:15310,y:390,text:'「想要」',taken:false},{x:18180,y:305,text:'「被找到」',taken:false},
{x:23020,y:305,text:'「真正的我」',taken:false},{x:26150,y:305,text:'「活下去」',taken:false},
{x:29820,y:390,text:'「下雨以后」',taken:false},{x:32360,y:305,text:'「绕一点路」',taken:false},
{x:34750,y:390,text:'「也没有关系」',taken:false},{x:37420,y:305,text:'「我不想再」',taken:false},
{x:39760,y:390,text:'「只回答正确答案」',taken:false},{x:42140,y:305,text:'「请听我说」',taken:false},
{x:44480,y:390,text:'「这是我的」',taken:false},{x:46850,y:305,text:'「第一首歌」',taken:false}
{x:34600,y:401,text:'「也没有关系」',taken:false},{x:37420,y:305,text:'「我不想再」',taken:false},
{x:39760,y:316,text:'「只回答正确答案」',taken:false},{x:42140,y:305,text:'「请听我说」',taken:false},
{x:44480,y:486,text:'「这是我的」',taken:false},{x:46950,y:316,text:'「第一首歌」',taken:false}
];
const ROOM_LAYOUTS = [
@@ -206,7 +206,7 @@
{ground:[[0,2400]],ledges:[[430,525,320],[850,440,320],[1290,355,360],[1780,440,330]]}
];
const platforms=ROOM_LAYOUTS.flatMap((layout,index)=>{const start=index*ROOM_W;return[...layout.ground.map(([x,w])=>({x:start+x,y:610,w,h:130})),...layout.ledges.map(([x,y,w])=>({x:start+x,y,w,h:24}))];});
const spikes = [{x:3850,y:592,w:100},{x:5310,y:592,w:100},{x:11100,y:592,w:110},{x:13300,y:592,w:110},{x:18300,y:592,w:100},{x:19700,y:592,w:110},{x:20850,y:592,w:100},{x:25400,y:592,w:110},{x:29620,y:592,w:100},{x:31640,y:592,w:110},{x:36940,y:592,w:110},{x:39320,y:592,w:110},{x:43780,y:592,w:100}];
const spikes = [{x:3850,y:592,w:100},{x:5310,y:592,w:100},{x:11100,y:592,w:110},{x:13300,y:592,w:110},{x:18300,y:592,w:100},{x:19700,y:592,w:110},{x:20850,y:592,w:100},{x:25400,y:592,w:110},{x:29660,y:592,w:100},{x:31640,y:592,w:110},{x:36940,y:592,w:110},{x:39320,y:592,w:110},{x:43780,y:592,w:100}];
const door = {x:15720,y:380,w:48,h:230};
const shrine = {x:10020,y:490,w:92,h:120,taken:false,kind:'shrine'};
const airShrine = {x:34620,y:490,w:92,h:120,taken:false,kind:'airShrine'};
@@ -219,16 +219,16 @@
{x:41040,y:510,w:180,h:100,kind:'bench'},
{x:45840,y:510,w:180,h:100,kind:'bench'}
];
const relays = [{x:10500,y:552,w:36,h:58,pair:'aquarium'},{x:13980,y:467,w:36,h:58,pair:'aquarium'},{x:31980,y:552,w:36,h:58,pair:'rain'},{x:41880,y:467,w:36,h:58,pair:'rain'}];
const relays = [{x:10500,y:552,w:36,h:58,pair:'aquarium'},{x:13980,y:467,w:36,h:58,pair:'aquarium'},{x:31980,y:552,w:36,h:58,pair:'rain'},{x:41880,y:382,w:36,h:58,pair:'rain'}];
const terminals = [
{x:260,y:500,w:108,h:110,id:'entry',kind:'terminal',title:'未发送的登录记录',speaker:'SYSTEM',text:'25:00。账号「雪」仍在线,但语音轨道没有输入。'},
{x:7850,y:500,w:108,h:110,id:'aquarium',kind:'terminal',title:'水族馆记忆:蓝色',speaker:'K',text:'你说喜欢水族馆的时候,声音没有在说谎。'},
{x:17060,y:500,w:108,h:110,id:'nightcord',kind:'terminal',title:'Nightcord 断线缓存',speaker:'Enanan',text:'连接断掉也没关系。想说的时候,再把真正的话发给我们。'},
{x:24260,y:500,w:108,h:110,id:'backstage',kind:'terminal',title:'无声舞台:演出指令',speaker:'まふゆ',text:'这次,我不想按照别人写好的台词笑。'},
{x:29480,y:500,w:108,h:110,id:'rooftop',kind:'terminal',title:'雨幕天台:未发送语音',speaker:'Amia',text:'偶尔绕路也可以呀。没有人规定你必须马上到达正确答案。'},
{x:28890,y:500,w:108,h:110,id:'rooftop',kind:'terminal',title:'雨幕天台:未发送语音',speaker:'Amia',text:'偶尔绕路也可以呀。没有人规定你必须马上到达正确答案。'},
{x:34080,y:500,w:108,h:110,id:'classroom',kind:'terminal',title:'镜像教室:值日日志',speaker:'Enanan',text:'镜子里的笑不是假的,只是你不必永远维持它。'},
{x:41320,y:500,w:108,h:110,id:'hall',kind:'terminal',title:'失声礼堂:空白谱面',speaker:'K',text:'第一小节不用完整。只要是你写下的,就足够开始。'},
{x:43880,y:500,w:108,h:110,id:'dressing',kind:'terminal',title:'无名化妆间:卸下的面具',speaker:'まふゆ',text:'我还不知道真正的自己是什么。但我想继续寻找。'}
{x:40520,y:500,w:108,h:110,id:'hall',kind:'terminal',title:'失声礼堂:空白谱面',speaker:'K',text:'第一小节不用完整。只要是你写下的,就足够开始。'},
{x:43480,y:500,w:108,h:110,id:'dressing',kind:'terminal',title:'无名化妆间:卸下的面具',speaker:'まふゆ',text:'我还不知道真正的自己是什么。但我想继续寻找。'}
];
const memoryLamps = [
{x:30240,y:470,w:86,h:140,kind:'lamp',id:'roof',lit:false},{x:32640,y:470,w:86,h:140,kind:'lamp',id:'rain',lit:false},
@@ -240,7 +240,7 @@
{x:9780,y:430,w:980,h:180,label:'共鸣静室'},{x:16920,y:430,w:700,h:180,label:'断线静默区'},
{x:21720,y:430,w:760,h:180,label:'后台休息站'},{x:24120,y:430,w:700,h:180,label:'幕间静默区'},
{x:28800,y:430,w:520,h:180,label:'天台雨棚'},{x:33600,y:430,w:760,h:180,label:'镜像教室静区'},
{x:36000,y:430,w:620,h:180,label:'放学路候车亭'},{x:40800,y:430,w:720,h:180,label:'礼堂前厅'},
{x:36000,y:430,w:620,h:180,label:'放学路候车亭'},{x:40320,y:430,w:480,h:180,label:'谱库静读区'},{x:40800,y:430,w:720,h:180,label:'礼堂前厅'},{x:43200,y:430,w:920,h:180,label:'化妆间静区'},
{x:45600,y:430,w:560,h:180,label:'最终幕准备区'}
];
const safeZoneGlow=ctx.createLinearGradient(0,430,0,610);safeZoneGlow.addColorStop(0,'rgba(143,241,245,0)');safeZoneGlow.addColorStop(1,'rgba(143,241,245,.12)');
@@ -860,7 +860,10 @@
}else if(e.type==='sentinel'){
e.y=approach(e.y,e.homeY+Math.sin(e.t*1.6)*10,38*dt);if(e.state==='alert'){holdEnemyFacing(e,Math.abs(dx)>32?Math.sign(dx):0);if(e.attackClock<=0){for(let i=-1;i<=1;i++){const a=Math.atan2(player.y-e.y,dx)+i*.17;fireProjectile(e.x+21,e.y+25,Math.cos(a)*210,Math.sin(a)*210,'note');}playSfx('enemyShot',.42,.92);e.attackClock=2.65;}}
}else if(e.type==='maskling'){
const config=ENEMY_AI.maskling,targetX=e.state==='alert'?e.lastSeenX:e.homeX+Math.sin(e.t*.72)*config.roam,targetY=e.state==='alert'?player.y+8:e.homeY+Math.sin(e.t*2.1)*28;e.dir=holdEnemyFacing(e,Math.abs(targetX-e.x)>24?Math.sign(targetX-e.x):0,.2);e.x=approach(e.x,targetX,(e.state==='alert'?config.chase:config.patrol)*dt);e.y=approach(e.y,targetY,(e.state==='alert'?88:44)*dt);if(e.state==='alert'&&e.attackClock<=0&&near<420){const d=Math.hypot(dx,player.y-e.y)||1;e.vx=dx/d*330;e.vy=(player.y-e.y)/d*260;e.attackClock=2.05;playSfx('enemyShot',.32,1.34);}
const config=ENEMY_AI.maskling,targetX=e.state==='alert'?e.lastSeenX:e.homeX+Math.sin(e.t*.72)*config.roam,targetY=e.state==='alert'?player.y+8:e.homeY+Math.sin(e.t*2.1)*28;e.dir=holdEnemyFacing(e,Math.abs(targetX-e.x)>24?Math.sign(targetX-e.x):0,.2);
if(e.attackClock>1.58){e.x+=e.vx*dt;e.y+=e.vy*dt;e.vx*=Math.pow(.2,dt);e.vy*=Math.pow(.24,dt);}
else{e.x=approach(e.x,targetX,(e.state==='alert'?config.chase:config.patrol)*dt);e.y=approach(e.y,targetY,(e.state==='alert'?88:44)*dt);}
if(e.state==='alert'&&e.attackClock<=0&&near<420){const d=Math.hypot(dx,player.y-e.y)||1;e.vx=dx/d*330;e.vy=(player.y-e.y)/d*260;e.attackClock=2.05;playSfx('enemyShot',.32,1.34);}
}else if(e.type==='metronome'){
const config=ENEMY_AI.metronome;steerGroundEnemy(e,dt,e.state==='alert'?config.chase:config.patrol,e.state==='alert'?590:280);moveGroundEnemySafely(e,dt);if(e.state==='alert'&&e.attackClock<=0&&near<390){const a=Math.atan2(player.y+30-(e.y+34),dx);fireProjectile(e.x+e.w/2,e.y+34,Math.cos(a)*255,Math.sin(a)*255,'blade');playSfx('enemyShot',.38,.76);e.attackClock=2.4;}
}else if(e.type==='rainChoir'){
@@ -879,7 +882,7 @@
}
}else if(e.type==='mirror'){
if(!finalArenaActive)continue;e.phase=e.hp<e.maxHp*.34?2:e.hp<e.maxHp*.68?1:0;const facing=Math.abs(dx)>44?Math.sign(dx):e.dir;holdEnemyFacing(e,facing,.13);e.vy=Math.min(900,e.vy+1700*dt);if(near>210)e.vx=approach(e.vx,e.dir*(105+e.phase*26),410*dt);else e.vx*=Math.pow(.035,dt);moveEntity(e,dt);
if(e.attackClock<=0){const pattern=(Math.floor(e.t*2.7)+e.phase)%3;if(pattern===0){const count=7+e.phase*2;for(let i=0;i<count;i++){const a=-Math.PI*.92+i*(Math.PI*1.84/(count-1));fireProjectile(e.x+e.w/2,e.y+42,Math.cos(a)*(205+e.phase*24),Math.sin(a)*(205+e.phase*24),'script');}}else if(pattern===1){const room=ROOMS[19];for(let i=0;i<6+e.phase;i++){const x=room.start+190+((i*337+Math.floor(e.t*100))%(ROOM_W-380));fireProjectile(x,70+(i%2)*34,(i%2?28:-28),235+e.phase*24,'rain');}}else{e.dir=Math.sign(dx)||e.dir;e.vx=e.dir*(430+e.phase*70);player.invuln=Math.max(player.invuln,.08);spawn(e.x+e.w/2,e.y+64,'#f4a8e4',18,190);}e.attackClock=2.15-e.phase*.32;shake=8+e.phase*2;playSfx('bossCast',.78,.92+e.phase*.06);tone(118,.28,'sawtooth',.03);}
if(e.attackClock<=0){const pattern=(Math.floor(e.t*2.7)+e.phase)%3;if(pattern===0){const count=7+e.phase*2;for(let i=0;i<count;i++){const a=-Math.PI*.92+i*(Math.PI*1.84/(count-1));fireProjectile(e.x+e.w/2,e.y+42,Math.cos(a)*(205+e.phase*24),Math.sin(a)*(205+e.phase*24),'script');}}else if(pattern===1){const room=ROOMS[19];for(let i=0;i<6+e.phase;i++){const x=room.start+190+((i*337+Math.floor(e.t*100))%(ROOM_W-380));fireProjectile(x,70+(i%2)*34,(i%2?28:-28),235+e.phase*24,'rain');}}else{e.dir=Math.sign(dx)||e.dir;e.vx=e.dir*(430+e.phase*70);spawn(e.x+e.w/2,e.y+64,'#f4a8e4',18,190);}e.attackClock=2.15-e.phase*.32;shake=8+e.phase*2;playSfx('bossCast',.78,.92+e.phase*.06);tone(118,.28,'sawtooth',.03);}
}
repelEnemyFromSafeZones(e);containEnemyInHomeRoom(e);
if(!isBossType(e.type)&&e.y>H+120){onEnemyDefeated(e);continue;}
+50
View File
@@ -0,0 +1,50 @@
"""Print alpha bounding boxes and foot-centered anchors for generated sprite sheets."""
from pathlib import Path
from PIL import Image
SHEETS = {
"idle": ("mafuyu-idle.png", 4, 1),
"run": ("mafuyu-run.png", 4, 2),
"jump": ("mafuyu-jump.png", 4, 1),
"attack": ("mafuyu-attack.png", 4, 1),
"boss": ("mafuyu-boss.png", 4, 4),
"enemies": ("sekai-enemies.png", 4, 4),
"interactions": ("mafuyu-interactions-v2.png", 4, 4),
"interactables": ("sekai-interactables.png", 4, 4),
}
def frames(path: Path, columns: int, rows: int):
image = Image.open(path).convert("RGBA")
cell_w, cell_h = image.width // columns, image.height // rows
output = []
for row in range(rows):
for column in range(columns):
left, top = column * cell_w, row * cell_h
alpha = image.crop((left, top, left + cell_w, top + cell_h)).getchannel("A")
bbox = alpha.getbbox()
if not bbox:
raise RuntimeError(f"Empty cell {column}, {row} in {path.name}")
x0, y0, x1, y1 = bbox
padding = 6
x0, y0 = max(0, x0 - padding), max(0, y0 - padding)
x1, y1 = min(cell_w, x1 + padding), min(cell_h, y1 + padding)
source_x, source_y = left + x0, top + y0
# The model was centered in each authored cell. Keep that point as the
# horizontal body anchor even when a sword trail expands the alpha box.
anchor_x = left + cell_w / 2 - source_x
output.append({
"sx": source_x,
"sy": source_y,
"sw": x1 - x0,
"sh": y1 - y0,
"ax": round(anchor_x, 1),
"ay": y1 - y0,
})
return output
root = Path(__file__).resolve().parents[1] / "assets"
for state, (filename, columns, rows) in SHEETS.items():
print(f"{state}: {frames(root / filename, columns, rows)},")
+49
View File
@@ -0,0 +1,49 @@
import { readFileSync } from 'node:fs';
import { performance } from 'node:perf_hooks';
const source = readFileSync(new URL('../game.js', import.meta.url), 'utf8');
const literal = name => {
const marker = `const ${name} = [`;
const start = source.indexOf(marker);
if (start < 0) throw new Error(`Missing ${name}`);
const body = start + marker.length - 1;
let depth = 0;
for (let index = body; index < source.length; index++) {
if (source[index] === '[') depth++;
if (source[index] === ']' && --depth === 0) return source.slice(body, index + 1);
}
throw new Error(`Unclosed ${name}`);
};
const roomWidth = Number(source.match(/ROOM_W = (\d+)/)?.[1]);
const layouts = Function(`return ${literal('ROOM_LAYOUTS')}`)();
const platforms = layouts.flatMap((layout, room) => {
const start = room * roomWidth;
return [
...layout.ground.map(([x, w]) => ({ x: start + x, y: 610, w, h: 130 })),
...layout.ledges.map(([x, y, w]) => ({ x: start + x, y, w, h: 24 }))
];
});
const byRoom = layouts.map((_, room) => platforms.filter(platform => Math.floor(platform.x / roomWidth) === room));
const entity = { x: 180, y: 505, w: 38, h: 78 };
const overlap = (a, b) => a.x < b.x + b.w && a.x + a.w > b.x && a.y < b.y + b.h && a.y + a.h > b.y;
const iterations = 180_000;
const run = candidates => {
let hits = 0;
const started = performance.now();
for (let iteration = 0; iteration < iterations; iteration++) {
entity.x = (iteration * 37) % roomWidth;
for (const platform of candidates) if (overlap(entity, platform)) hits++;
}
return { ms: performance.now() - started, hits };
};
const globalScan = run(platforms);
const localScan = run(byRoom[0]);
const ratio = platforms.length / byRoom[0].length;
console.log(`Global candidates per pass: ${platforms.length}`);
console.log(`Room-local candidates per pass: ${byRoom[0].length}`);
console.log(`Candidate reduction: ${ratio.toFixed(2)}x`);
console.log(`Synthetic ${iterations.toLocaleString()}-pass scan: ${globalScan.ms.toFixed(2)}ms -> ${localScan.ms.toFixed(2)}ms`);
if (globalScan.hits !== localScan.hits || ratio < 8) process.exitCode = 1;
+41
View File
@@ -0,0 +1,41 @@
$ErrorActionPreference = 'Stop'
$root = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
$sources = Join-Path $root '.tmp\audio-downloads'
$output = Join-Path $root 'assets\audio\attack-candidates'
New-Item -ItemType Directory -Path $output -Force | Out-Null
function Invoke-FFmpeg([string[]]$Arguments) {
& ffmpeg @Arguments
if ($LASTEXITCODE -ne 0) { throw "ffmpeg failed with exit code $LASTEXITCODE" }
}
function Convert-Candidate([string]$Source, [string]$Name, [string]$Filter = 'loudnorm=I=-18:TP=-2:LRA=7') {
$target = Join-Path $output $Name
Invoke-FFmpeg @('-y','-v','error','-i',$Source,'-af',$Filter,'-ac','1','-ar','48000','-c:a','libvorbis','-q:a','5',$target)
}
$swishRoot = Join-Path $sources 'swishes\swishes'
foreach ($number in 1,2,3,4,7,8,9,12) {
Convert-Candidate (Join-Path $swishRoot "swish-$number.wav") ("physical-swish-{0:d2}.ogg" -f $number)
}
Convert-Candidate (Join-Path $sources 'rpg\Audio\knifeSlice.ogg') 'physical-knife-slice-alt.ogg'
Convert-Candidate (Join-Path $sources 'digital\Audio\phaserUp2.ogg') 'energy-phaser-rise.ogg'
Convert-Candidate (Join-Path $sources 'digital\Audio\phaseJump2.ogg') 'energy-phase-snap.ogg'
Convert-Candidate (Join-Path $sources 'digital\Audio\laser3.ogg') 'energy-laser-short.ogg' 'atrim=0:0.55,asetpts=PTS-STARTPTS,afade=t=out:st=0.42:d=0.13,loudnorm=I=-18:TP=-2:LRA=7'
Convert-Candidate (Join-Path $sources 'magic-spell\magical_1.ogg') 'energy-magic-01-short.ogg' 'atrim=0:0.58,asetpts=PTS-STARTPTS,afade=t=out:st=0.43:d=0.15,loudnorm=I=-18:TP=-2:LRA=7'
Convert-Candidate (Join-Path $sources 'magic-spell\magical_2.ogg') 'energy-magic-02-short.ogg' 'atrim=0:0.58,asetpts=PTS-STARTPTS,afade=t=out:st=0.43:d=0.15,loudnorm=I=-18:TP=-2:LRA=7'
Convert-Candidate (Join-Path $sources 'magic-spell\magical_3.ogg') 'energy-magic-03-short.ogg' 'atrim=0:0.58,asetpts=PTS-STARTPTS,afade=t=out:st=0.43:d=0.15,loudnorm=I=-18:TP=-2:LRA=7'
function Mix-Candidate([string]$First, [string]$Second, [string]$Name, [double]$SecondVolume, [int]$DelayMs = 0) {
$target = Join-Path $output $Name
$filter = "[0:a]volume=0.92[a];[1:a]atrim=0:0.58,asetpts=PTS-STARTPTS,volume=$SecondVolume,adelay=$DelayMs|$DelayMs[b];[a][b]amix=inputs=2:duration=longest:normalize=0,loudnorm=I=-18:TP=-2:LRA=7[out]"
Invoke-FFmpeg @('-y','-v','error','-i',$First,'-i',$Second,'-filter_complex',$filter,'-map','[out]','-ac','1','-ar','48000','-c:a','libvorbis','-q:a','5',$target)
}
Mix-Candidate (Join-Path $swishRoot 'swish-3.wav') (Join-Path $sources 'digital\Audio\phaserUp2.ogg') 'layered-swish-phaser.ogg' .48 8
Mix-Candidate (Join-Path $swishRoot 'swish-7.wav') (Join-Path $sources 'magic-spell\magical_2.ogg') 'layered-swish-magic.ogg' .30 12
Mix-Candidate (Join-Path $sources 'rpg\Audio\knifeSlice.ogg') (Join-Path $sources 'digital\Audio\phaseJump2.ogg') 'layered-knife-phase.ogg' .42 0
Write-Host "Built attack candidates in $output"
+135
View File
@@ -0,0 +1,135 @@
"""Normalize AI expansion art into fixed-anchor sixteen-frame runtime atlases.
The source sheets are generated as complete 4x4 grids. This builder keeps one
shared scale and anchor per animation row, motion-interpolates key poses, and
packs every runtime row into sixteen isolated cells so Canvas never needs to
cross-fade two full silhouettes.
"""
from __future__ import annotations
from pathlib import Path
import cv2
import numpy as np
from PIL import Image, ImageDraw
from build_high_frame_atlases import (
border_alpha,
motion_interpolate,
normalize_keyframes,
pack_rows,
seamless_sixteen,
split_grid,
)
ROOT = Path(__file__).resolve().parents[1]
ASSETS = ROOT / "assets"
def grid_rows(path: Path, size: tuple[int, int], padding: int) -> list[list[Image.Image]]:
source = Image.open(path).convert("RGBA")
cells = split_grid(source, 4, 4)
return [normalize_keyframes(cells[row * 4:(row + 1) * 4], size, padding) for row in range(4)]
def sequence_sixteen(keys: list[Image.Image]) -> list[Image.Image]:
"""Create a readable non-looping 16-frame action from four authored poses."""
output: list[Image.Image] = []
steps = (5, 5, 6)
for segment, count in enumerate(steps):
first, second = keys[segment], keys[segment + 1]
for index in range(count):
amount = index / count
output.append(first if index == 0 else motion_interpolate(first, second, amount))
output[-1] = keys[-1]
return output
def remove_tiny_components(frame: Image.Image, min_area: int = 110) -> Image.Image:
rgba = np.asarray(frame.convert("RGBA"), dtype=np.uint8).copy()
count, labels, stats, _ = cv2.connectedComponentsWithStats((rgba[:, :, 3] > 12).astype(np.uint8), 8)
for component in range(1, count):
if stats[component, cv2.CC_STAT_AREA] < min_area:
rgba[labels == component] = 0
return Image.fromarray(rgba, "RGBA")
def remove_components_above_main(frame: Image.Image) -> Image.Image:
"""Drop shoe/hair fragments leaked from the previous generated grid row."""
rgba = np.asarray(frame.convert("RGBA"), dtype=np.uint8).copy()
count, labels, stats, _ = cv2.connectedComponentsWithStats((rgba[:, :, 3] > 12).astype(np.uint8), 8)
if count <= 2:
return frame
main = 1 + int(np.argmax(stats[1:, cv2.CC_STAT_AREA]))
main_top = int(stats[main, cv2.CC_STAT_TOP])
for component in range(1, count):
if component != main and int(stats[component, cv2.CC_STAT_TOP]) < main_top:
rgba[labels == component] = 0
return Image.fromarray(rgba, "RGBA")
def build() -> None:
enemy_sources = [
"enemy-maskling-16-alpha.png",
"enemy-metronome-16-alpha.png",
"enemy-rain-choir-16-alpha.png",
"enemy-mirror-hound-16-alpha.png",
]
enemy_rows = []
for filename in enemy_sources:
source = Image.open(ASSETS / filename).convert("RGBA")
enemy_rows.append(normalize_keyframes(split_grid(source, 4, 4), (192, 160), 16))
pack_rows(enemy_rows, ASSETS / "sekai-expansion-enemies-16.png")
prop_keys = grid_rows(ASSETS / "sekai-expansion-interactables-alpha.png", (224, 224), 18)
prop_rows = [seamless_sixteen(row) for row in prop_keys]
pack_rows(prop_rows, ASSETS / "sekai-expansion-interactables-16.png")
boss_sources = [
"mafuyu-final-boss-idle-16-alpha.png",
"mafuyu-final-boss-cast-16-alpha.png",
"mafuyu-final-boss-dash-16-alpha.png",
"mafuyu-final-boss-defeat-16-alpha.png",
]
boss_rows = []
for row, filename in enumerate(boss_sources):
source = Image.open(ASSETS / filename).convert("RGBA")
raw = split_grid(source, 4, 4)
if row == 1:
raw = [raw[index] for index in [*range(12), 8, 5, 2, 0]]
frames = [remove_components_above_main(frame) for frame in normalize_keyframes(raw, (256, 256), 18)]
boss_rows.append([remove_tiny_components(frame) if row == 0 else frame for frame in frames])
pack_rows(boss_rows, ASSETS / "mafuyu-final-boss-16.png")
for label, rows in (("enemy", enemy_rows), ("prop", prop_rows), ("boss", boss_rows)):
if any(border_alpha(frame) > 12 for row in rows for frame in row):
raise RuntimeError(f"{label} expansion atlas touches a frame border")
preview = Image.new("RGBA", (1120, 2400), (10, 10, 24, 255))
draw = ImageDraw.Draw(preview)
groups = [
("NEW SEKAI ENEMIES", enemy_rows, 150),
("NEW INTERACTABLES", prop_rows, 170),
("THE UNWRITTEN MAFUYU", boss_rows, 180),
]
y = 18
for label, rows, thumb_size in groups:
draw.text((20, y), label, fill=(220, 211, 255, 255))
y += 28
for row in rows:
for column, index in enumerate((0, 3, 6, 9, 12, 15)):
frame = row[index].copy()
frame.thumbnail((thumb_size, thumb_size), Image.Resampling.LANCZOS)
x = 18 + column * 182 + (thumb_size - frame.width) // 2
preview.alpha_composite(frame, (x, y + thumb_size - frame.height))
y += thumb_size + 8
y += 20
preview.crop((0, 0, preview.width, min(preview.height, y))).save(
ASSETS / "expansion-animation-preview.png", optimize=True
)
print("Built expansion enemy, prop, and final-boss 16-frame atlases.")
if __name__ == "__main__":
build()
+244
View File
@@ -0,0 +1,244 @@
"""Build fixed-cell 16-frame combat, enemy, and interactable atlases.
AI character sheets are kept as one-strip generations. Existing four-keyframe
world sprites are normalized with one shared scale and motion-warped into a
seamless 16-frame loop so runtime rendering never cross-fades two silhouettes.
"""
from __future__ import annotations
from pathlib import Path
import cv2
import numpy as np
from PIL import Image, ImageDraw
ROOT = Path(__file__).resolve().parents[1]
ASSETS = ROOT / "assets"
ENEMY_RECTS = [
[(194, 66, 220, 149), (544, 46, 232, 168), (905, 63, 382, 151), (1287, 62, 284, 152)],
[(156, 260, 269, 182), (535, 259, 259, 184), (906, 262, 381, 182), (1287, 262, 244, 181)],
[(131, 490, 298, 197), (429, 461, 385, 226), (858, 469, 429, 218), (1287, 495, 301, 192)],
[(167, 687, 173, 184), (517, 687, 341, 181), (858, 687, 429, 186), (1287, 687, 238, 186)],
]
INTERACTABLE_RECTS = [
[(20, 92, 271, 187), (331, 92, 270, 187), (644, 92, 271, 187), (957, 92, 270, 187)],
[(62, 353, 187, 253), (368, 353, 197, 253), (684, 353, 196, 253), (994, 353, 191, 253)],
[(76, 660, 159, 233), (379, 660, 178, 233), (687, 660, 185, 233), (1000, 660, 198, 233)],
[(44, 958, 237, 241), (355, 958, 237, 241), (669, 959, 237, 240), (981, 958, 237, 241)],
]
def split_grid(image: Image.Image, columns: int, rows: int) -> list[Image.Image]:
frames: list[Image.Image] = []
for row in range(rows):
for column in range(columns):
left = round(column * image.width / columns)
right = round((column + 1) * image.width / columns)
top = round(row * image.height / rows)
bottom = round((row + 1) * image.height / rows)
frames.append(image.crop((left, top, right, bottom)))
return frames
def pack_grid(frames: list[Image.Image], columns: int, out: Path) -> None:
width, height = frames[0].size
rows = (len(frames) + columns - 1) // columns
atlas = Image.new("RGBA", (columns * width, rows * height), (0, 0, 0, 0))
for index, frame in enumerate(frames):
atlas.alpha_composite(frame, ((index % columns) * width, (index // columns) * height))
atlas.save(out, optimize=True)
def crop_rect(image: Image.Image, rect: tuple[int, int, int, int]) -> Image.Image:
x, y, width, height = rect
return image.crop((x, y, x + width, y + height))
def normalize_keyframes(frames: list[Image.Image], size: tuple[int, int], padding: int) -> list[Image.Image]:
cropped: list[Image.Image] = []
for frame in frames:
bbox = frame.getchannel("A").point(lambda value: 255 if value > 8 else 0).getbbox()
if bbox is None:
raise RuntimeError("Empty sprite keyframe")
cropped.append(frame.crop(bbox))
max_width = max(frame.width for frame in cropped)
max_height = max(frame.height for frame in cropped)
scale = min((size[0] - padding * 2) / max_width, (size[1] - padding * 2) / max_height)
output: list[Image.Image] = []
for frame in cropped:
resized = frame.resize((round(frame.width * scale), round(frame.height * scale)), Image.Resampling.LANCZOS)
canvas = Image.new("RGBA", size, (0, 0, 0, 0))
canvas.alpha_composite(resized, ((size[0] - resized.width) // 2, size[1] - padding - resized.height))
output.append(canvas)
return output
def rgba_array(image: Image.Image) -> np.ndarray:
return np.asarray(image.convert("RGBA"), dtype=np.uint8).copy()
def flow_gray(rgba: np.ndarray) -> np.ndarray:
alpha = rgba[:, :, 3:4].astype(np.float32) / 255
rgb = rgba[:, :, :3].astype(np.float32) * alpha + np.array([0, 255, 0], dtype=np.float32) * (1 - alpha)
return cv2.cvtColor(rgb.astype(np.uint8), cv2.COLOR_RGB2GRAY)
def warp(rgba: np.ndarray, flow: np.ndarray, amount: float) -> np.ndarray:
height, width = rgba.shape[:2]
grid_x, grid_y = np.meshgrid(np.arange(width, dtype=np.float32), np.arange(height, dtype=np.float32))
return cv2.remap(rgba, grid_x - flow[:, :, 0] * amount, grid_y - flow[:, :, 1] * amount,
interpolation=cv2.INTER_LINEAR, borderMode=cv2.BORDER_CONSTANT, borderValue=(0, 0, 0, 0))
def motion_interpolate(first: Image.Image, second: Image.Image, amount: float) -> Image.Image:
a, b = rgba_array(first), rgba_array(second)
gray_a, gray_b = flow_gray(a), flow_gray(b)
options = dict(pyr_scale=0.5, levels=4, winsize=25, iterations=4, poly_n=7, poly_sigma=1.5, flags=0)
forward = cv2.calcOpticalFlowFarneback(gray_a, gray_b, None, **options)
backward = cv2.calcOpticalFlowFarneback(gray_b, gray_a, None, **options)
warped_a = warp(a, forward, amount).astype(np.float32)
warped_b = warp(b, backward, 1 - amount).astype(np.float32)
mixed = np.clip(warped_a * (1 - amount) + warped_b * amount, 0, 255).astype(np.uint8)
mixed[:, :, 3] = np.maximum(warped_a[:, :, 3] * (1 - amount), warped_b[:, :, 3] * amount).astype(np.uint8)
return Image.fromarray(mixed, "RGBA")
def seamless_sixteen(keys: list[Image.Image]) -> list[Image.Image]:
output: list[Image.Image] = []
for index, first in enumerate(keys):
second = keys[(index + 1) % len(keys)]
output.extend([first, motion_interpolate(first, second, 0.25), motion_interpolate(first, second, 0.5), motion_interpolate(first, second, 0.75)])
return output
def pack_rows(rows: list[list[Image.Image]], out: Path) -> None:
cell_width, cell_height = rows[0][0].size
atlas = Image.new("RGBA", (cell_width * 16, cell_height * len(rows)), (0, 0, 0, 0))
for row, frames in enumerate(rows):
if len(frames) != 16:
raise RuntimeError(f"Row {row} has {len(frames)} frames")
for column, frame in enumerate(frames):
atlas.alpha_composite(frame, (column * cell_width, row * cell_height))
atlas.save(out, optimize=True)
def border_alpha(frame: Image.Image) -> int:
alpha = frame.getchannel("A")
edges = [alpha.crop((0, 0, alpha.width, 2)), alpha.crop((0, alpha.height - 2, alpha.width, alpha.height)),
alpha.crop((0, 0, 2, alpha.height)), alpha.crop((alpha.width - 2, 0, alpha.width, alpha.height))]
return max(int(np.asarray(edge).max(initial=0)) for edge in edges)
def remove_stray_dark_components(frame: Image.Image) -> Image.Image:
"""Remove detached dark body fragments while preserving bright note/frost FX."""
rgba = rgba_array(frame)
count, labels, stats, _ = cv2.connectedComponentsWithStats((rgba[:, :, 3] > 12).astype(np.uint8), 8)
if count <= 2:
return frame
main = 1 + int(np.argmax(stats[1:, cv2.CC_STAT_AREA]))
for component in range(1, count):
if component == main or stats[component, cv2.CC_STAT_AREA] >= 1500:
continue
mask = labels == component
colors = rgba[mask, :3]
if colors.size and float(colors.mean()) < 145:
rgba[mask] = 0
return Image.fromarray(rgba, "RGBA")
def inset_player_frames(frames: list[Image.Image], cell_size: int = 320, padding: int = 12) -> list[Image.Image]:
"""Preserve the authored cell-center anchor while guaranteeing safe gutters."""
output: list[Image.Image] = []
inner = cell_size - padding * 2
for frame in frames:
resized = frame.resize((inner, inner), Image.Resampling.LANCZOS)
canvas = Image.new("RGBA", (cell_size, cell_size), (0, 0, 0, 0))
canvas.alpha_composite(resized, (padding, padding))
output.append(remove_stray_dark_components(canvas))
return output
def procedural_sixteen(base: Image.Image, style: int) -> list[Image.Image]:
"""Create a clean single-silhouette loop without alpha-blending creatures."""
source = rgba_array(base)
height, width = source.shape[:2]
center = (width / 2, height / 2)
output: list[Image.Image] = []
for index in range(16):
phase = index / 16 * np.pi * 2
angle = np.sin(phase) * (1.1 if style in (1, 3) else 0.45)
scale = 1 + np.sin(phase + style * 0.7) * (0.012 if style != 2 else 0.018)
matrix = cv2.getRotationMatrix2D(center, angle, scale)
matrix[0, 2] += np.cos(phase) * (1.1 if style == 2 else 0.55)
matrix[1, 2] += np.sin(phase) * (2.2 if style == 1 else 1.15)
warped = cv2.warpAffine(source, matrix, (width, height), flags=cv2.INTER_CUBIC,
borderMode=cv2.BORDER_CONSTANT, borderValue=(0, 0, 0, 0))
output.append(Image.fromarray(warped, "RGBA"))
return output
def build_player_atlases() -> None:
bow = Image.open(ASSETS / "mafuyu-ice-bow-alpha.png").convert("RGBA")
release = Image.open(ASSETS / "mafuyu-ice-release-alpha.png").convert("RGBA")
charge = Image.open(ASSETS / "mafuyu-ice-charge-alpha.png").convert("RGBA")
attack_source = Image.open(ASSETS / "mafuyu-attack-16-alpha.png").convert("RGBA")
bow_frames = inset_player_frames(split_grid(bow, 4, 4))
release_frames = inset_player_frames(split_grid(release, 4, 4))
charge_source = split_grid(charge, 4, 4)
# The generated bottom row touches the canvas edge. Use the twelve complete
# frames, then ease back through matching poses and finish on frame 01.
charge_order = [*range(12), 8, 5, 2, 0]
charge_frames = inset_player_frames([charge_source[index] for index in charge_order])
attack_frames = inset_player_frames(split_grid(attack_source, 4, 4))
pack_grid(attack_frames, 4, ASSETS / "mafuyu-attack-16.png")
pack_grid(bow_frames, 4, ASSETS / "mafuyu-ice-bow.png")
pack_grid(charge_frames, 4, ASSETS / "mafuyu-ice-charge.png")
pack_grid(release_frames, 4, ASSETS / "mafuyu-ice-release.png")
for label, frames in [("attack", attack_frames), ("bow", bow_frames), ("charge", charge_frames), ("release", release_frames)]:
if any(border_alpha(frame) > 12 for frame in frames):
raise RuntimeError(f"{label} atlas content touches a frame border")
def build_world_atlases() -> None:
enemy_source = Image.open(ASSETS / "sekai-enemies.png").convert("RGBA")
enemy_rows = []
for style, rects in enumerate(ENEMY_RECTS):
keys = normalize_keyframes([crop_rect(enemy_source, rect) for rect in rects], (192, 144), 8)
enemy_rows.append(procedural_sixteen(keys[0], style))
pack_rows(enemy_rows, ASSETS / "sekai-enemies-16.png")
object_source = Image.open(ASSETS / "sekai-interactables.png").convert("RGBA")
object_rows = []
for rects in INTERACTABLE_RECTS:
keys = normalize_keyframes([crop_rect(object_source, rect) for rect in rects], (192, 192), 8)
object_rows.append(seamless_sixteen(keys))
pack_rows(object_rows, ASSETS / "sekai-interactables-16.png")
def build_preview() -> None:
sources = [
("NOTE BLADE", Image.open(ASSETS / "mafuyu-attack-16.png").convert("RGBA"), 4, 4),
("ICE BOW", Image.open(ASSETS / "mafuyu-ice-bow.png").convert("RGBA"), 4, 4),
("CHARGED HOLD LOOP", Image.open(ASSETS / "mafuyu-ice-charge.png").convert("RGBA"), 4, 4),
("CHARGED RELEASE", Image.open(ASSETS / "mafuyu-ice-release.png").convert("RGBA"), 4, 4),
]
canvas = Image.new("RGBA", (1080, 1110), (14, 12, 24, 255))
draw = ImageDraw.Draw(canvas)
for row, (label, source, columns, rows) in enumerate(sources):
frames = split_grid(source, columns, rows)
draw.text((20, 18 + row * 270), label, fill=(217, 205, 255, 255))
for column, index in enumerate([0, 3, 6, 9, 12, 15]):
frame = frames[index]
thumb = frame.copy()
thumb.thumbnail((160, 220), Image.Resampling.LANCZOS)
canvas.alpha_composite(thumb, (20 + column * 176 + (160 - thumb.width) // 2, 44 + row * 270 + 210 - thumb.height))
canvas.save(ASSETS / "combat-animation-preview.png", optimize=True)
if __name__ == "__main__":
build_player_atlases()
build_world_atlases()
build_preview()
print("Built 16-frame player, enemy, and interactable atlases.")

Some files were not shown because too many files have changed in this diff Show More