学习路径Learning path · 第 2 阶段Stage 2
S2 · 核心循环
S2 · The core loop
这一步决定什么:把「玩法」变成「能跑的东西」。这是 AI 帮得最明显的一段 —— 也是最容易骗自己的一段。
What this stage decides: turning "a gameplay idea" into "something that runs". This is where AI helps most — and where it most easily deceives you.
为什么这段最容易
核心循环是确定性代码:玩家按键 → 状态更新 → 画面变化 → 等待输入。
它没有模糊的地方,没有需要判断力的地方。AI 写这类代码的错得最少。
Why this stage is the easiest
The core loop is deterministic code: the player presses a key → state updates → the view changes → wait for input.
Nothing here is ambiguous, nothing here needs judgement. AI makes the fewest mistakes on this kind of code.
提示词该给什么
⚠ 别只说「做一个平台跳跃游戏」 —— 你会得到一堆跑不起来的脚手架。
要给三样东西:
| 要给什么 | 例子 |
|---|---|
| 具体的输入 → 行为映射 | 「左键跳跃,松开时重力减半;有 coyote time 100ms」 |
| 数值 | 「跳跃初速 -420,重力 980,落地判定 y差 < 12」 |
| 明确的边界 | 「这一版只有移动和跳跃,不要加敌人、不要加 UI、不要加动画」 |
⚠ 第三条最容易漏。不说「不要做什么」,AI 会把所有可能的系统都写一遍,
然后你在调试器里花三天找为什么角色会掉出屏幕。
What to put in the prompt
⚠ Do not just say "make a platformer" — you will get scaffolding that does not run.
Give it three things:
| Give | Example |
|---|---|
| A concrete input → behaviour mapping | "Left click jumps, releasing it halves gravity; 100 ms of coyote time" |
| Actual numbers | "Jump velocity -420, gravity 980, landing check within 12 px" |
| Explicit boundaries | "This version is movement and jumping only. Do not add enemies, UI or animation" |
⚠ The third is the easiest to forget. Without "do not do X", AI writes every system it can think of — and then you spend three days in a debugger wondering why the character falls off the screen.
语言选择的影响
| 引擎 | 脚本语言 | AI 写它的表现 |
|---|---|---|
| Godot | GDScript | 好 —— 语法接近 Python,错误信息友好 |
| Godot | C# | 中 —— 需要 .NET 环境,AI 常写出版本不匹配的 API |
| Bevy | Rust | 差 —— 编译错误难读,AI 常写出能编译但借用检查失败的代码 |
| Pixi / Three | TypeScript | 好 —— 训练数据最多 |
⚠ 这不是实测数据,是我们的判断。Rust 的问题尤其明显:所有权模型对 AI 很不友好,
cannot borrow x as mutable because it is also borrowed as immutable 这类错误,
AI 无法从报错里定位正确。
How the language changes things
| Engine | Scripting | How AI does with it |
|---|---|---|
| Godot | GDScript | Good — syntax close to Python, friendly errors |
| Godot | C# | Middling — needs .NET, and AI often writes APIs from the wrong version |
| Bevy | Rust | Poor — compile errors are hard to read and AI often produces code that compiles but fails borrow checking |
| Pixi / Three | TypeScript | Good — by far the most training data |
⚠ This is our judgement, not measured. Rust is the clearest case: the ownership model is very unfriendly to AI, and with errors like cannot borrow x as mutable because it is also borrowed as immutable AI cannot locate the real problem.
常见失败
- 让 AI 一次写完整个游戏 —— 你会得到一个跑不起来的大文件
- 不检查就往下走 —— 核心循环没跑通就去改手感,等于在坏地基上盖楼
- 接受「能跑」作为完成标准 —— 见 S3,这是最关键的一步
Common failures
- Asking AI to write the whole game at once — you get one big file that does not run.
- Moving on without checking — if the core loop does not run, tuning game feel is building on a broken foundation.
- Treating "it runs" as done — see S3. This is the single most important step.
判断你这一步做完了吗
- 核心循环能跑,且每次输入都有可见反馈
- 你玩过 10 分钟以上(不是跑起来就看一眼)
- 数值是具体值,不是「大概 400」
Are you done with this stage?
- The core loop runs and every input has visible feedback
- You have played it for more than 10 minutes (not just started it once)
- The numbers are actual values, not "about 400"