Add Switch game framework target
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
#version 330 core
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
|
||||
in vec4 v_color;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#version 330 core
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
|
||||
layout (location = 0) in vec2 a_position;
|
||||
layout (location = 1) in vec2 a_texCoord;
|
||||
layout (location = 2) in vec4 a_color;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#version 330 core
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
|
||||
in vec2 v_texCoord;
|
||||
in vec4 v_color;
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#version 330 core
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
|
||||
layout (location = 0) in vec2 a_position;
|
||||
layout (location = 1) in vec2 a_texCoord;
|
||||
layout (location = 2) in vec4 a_color;
|
||||
|
||||
@@ -21,6 +21,7 @@ game/
|
||||
├─ movement/ 可复用的移动和碰撞辅助工具
|
||||
├─ scene/ 游戏场景和关卡编排
|
||||
├─ stage/ 关卡视觉层渲染
|
||||
├─ switch_game_main.cpp Switch/NS 游戏入口
|
||||
└─ main.cpp 游戏可执行文件入口点
|
||||
```
|
||||
|
||||
@@ -99,8 +100,8 @@ main.cpp
|
||||
|
||||
## 当前构建目标
|
||||
|
||||
`xmake.lua` 为 Windows 定义 `Frostbite2DGame`。它编译所有
|
||||
`game/src/**.cpp` 文件,链接到 `Frostbite2D`,并在构建后
|
||||
`xmake.lua` 为 Windows 定义 `Frostbite2DGame`。它编译桌面游戏入口
|
||||
`game/src/main.cpp` 和所有通用游戏源码,链接到 `Frostbite2D`,并在构建后
|
||||
将 `game/assets` 复制到可执行文件旁边。
|
||||
|
||||
构建命令:
|
||||
@@ -115,6 +116,29 @@ xmake -b Frostbite2DGame
|
||||
build/windows/x64/release/Frostbite2DGame.exe
|
||||
```
|
||||
|
||||
Switch/NS 游戏框架目标为 `Frostbite2DGameSwitch`。它使用
|
||||
`game/src/switch_game_main.cpp` 作为平台入口,复用同一套 Scene、Stage、
|
||||
Actor、Movement、Debug 和 Data 模块。
|
||||
|
||||
构建命令:
|
||||
|
||||
```powershell
|
||||
xmake -b Frostbite2DGameSwitch
|
||||
```
|
||||
|
||||
输出:
|
||||
|
||||
```text
|
||||
build/switch/aarch64/release/Frostbite2DGame.elf
|
||||
build/switch/aarch64/release/switch_game/NSUnknownGame.nro
|
||||
```
|
||||
|
||||
Switch 运行时资源目录:
|
||||
|
||||
```text
|
||||
/switch/Frostbite2D/NS Unknown Game/assets
|
||||
```
|
||||
|
||||
## 后续架构步骤
|
||||
|
||||
1. 添加 `actor/enemy_actor.*` 并复用 `PlatformMover`
|
||||
|
||||
@@ -77,6 +77,7 @@ mindmap
|
||||
Hitbox可视化
|
||||
帧率与日志
|
||||
构建文档
|
||||
NS平台构建
|
||||
```
|
||||
|
||||
## 白板总览
|
||||
@@ -295,6 +296,26 @@ mindmap
|
||||
- 绘制 hitbox / hurtbox。
|
||||
- 输出当前场景、角色状态、FPS。
|
||||
|
||||
### 11. Platform
|
||||
|
||||
职责:
|
||||
|
||||
- 保持 PC 和 NS 共用游戏逻辑。
|
||||
- 只在入口、构建、资源部署、平台输入处做差异化。
|
||||
|
||||
已有:
|
||||
|
||||
- `game/src/main.cpp`:Windows/PC 游戏入口。
|
||||
- `game/src/switch_game_main.cpp`:Switch/NS 游戏入口。
|
||||
- `Frostbite2DGame`:Windows 游戏目标。
|
||||
- `Frostbite2DGameSwitch`:Switch 游戏目标,生成 `NSUnknownGame.nro`。
|
||||
|
||||
下一步:
|
||||
|
||||
- 将 Switch Joy-Con 输入接入 `InputStateProvider`。
|
||||
- 整理资源部署脚本,把 `assets` 放到 `/switch/Frostbite2D/NS Unknown Game/assets`。
|
||||
- 在 Ryujinx 或真机上验证主循环、shader 和角色纹理。
|
||||
|
||||
## 数据流白板
|
||||
|
||||
```text
|
||||
@@ -380,10 +401,11 @@ mindmap
|
||||
下一步建议按这个顺序做:
|
||||
|
||||
1. `BattleZone`:做清版推进的核心框架。
|
||||
2. `EnemyActor`:做第一个敌人占位。
|
||||
3. `CombatSystem`:把 hitbox/hurtbox 真正跑起来。
|
||||
4. `SpriteAnimator`:把玩家动画从硬编码改成组件。
|
||||
5. `StageLayer`:把白盒视觉层扩展为背景、tiles 和 props。
|
||||
2. `SwitchInput`:把 Joy-Con/手柄输入接入 `InputStateProvider`。
|
||||
3. `EnemyActor`:做第一个敌人占位。
|
||||
4. `CombatSystem`:把 hitbox/hurtbox 真正跑起来。
|
||||
5. `SpriteAnimator`:把玩家动画从硬编码改成组件。
|
||||
6. `StageLayer`:把白盒视觉层扩展为背景、tiles 和 props。
|
||||
|
||||
## 素材协作提示
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#include "core/game_config.h"
|
||||
#include "scene/whitebox_scene.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include <frostbite2D/core/application.h>
|
||||
#include <frostbite2D/scene/scene_manager.h>
|
||||
#include <switch.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
auto config = frostbite2D::AppConfig::createDefault();
|
||||
config.appName = "NS Unknown Game";
|
||||
config.windowConfig.title = "NS Unknown Game";
|
||||
config.windowConfig.width = ns_game::config::kVirtualWidth;
|
||||
config.windowConfig.height = ns_game::config::kVirtualHeight;
|
||||
config.windowConfig.resizable = false;
|
||||
config.windowConfig.vsync = true;
|
||||
config.useVirtualResolution = true;
|
||||
config.virtualWidth = ns_game::config::kVirtualWidth;
|
||||
config.virtualHeight = ns_game::config::kVirtualHeight;
|
||||
config.resolutionMode = frostbite2D::ResolutionScaleMode::Fit;
|
||||
config.renderStyleProfile = frostbite2D::RenderStyleProfileId::PixelArt2D;
|
||||
config.maxFps = 60;
|
||||
|
||||
auto& app = frostbite2D::Application::get();
|
||||
if (!app.init(config)) {
|
||||
std::puts("NS Unknown Game Switch init failed.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
app.run([]() {
|
||||
frostbite2D::SceneManager::get().ReplaceScene(
|
||||
frostbite2D::MakePtr<ns_game::WhiteboxScene>());
|
||||
});
|
||||
|
||||
app.shutdown();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user