From 4a6f4862de0c39f38dcb3c8e61fbabef545ca6d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?sijcdu=E7=9A=84=E6=B8=B8=E6=88=8F?= Date: Wed, 7 Oct 2026 23:14:52 +0800 Subject: [PATCH] Bring the jump back so the key warp can reach high ledges Space is bound to jump again, exactly as before: same action name, same physical_keycode 32, same jump_velocity -190 and gravity 980, so the measured jump height is 20.07 px, identical to the reading taken before the binding was removed. Single jump only, no double jump. The debug flight goes back to Space for up and S for down like it used to, with the arrow keys kept as an extra. No gameplay content touched. --- README.md | 7 ++----- project.godot | 3 ++- scripts/cheat_panel.gd.uid | 1 + scripts/player_controller.gd | 8 ++++---- 4 files changed, 9 insertions(+), 10 deletions(-) create mode 100644 scripts/cheat_panel.gd.uid diff --git a/README.md b/README.md index 2dbacf5..0b1f602 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ | 按键 | 作用 | |---|---| | `A` / `D` | 左右移动 | -| `空格` | (当前已停用,输入映射里的 `jump` 键位为空) | +| `空格` | 跳跃(单段,空中不能二段跳) | | `S` 按住 | 显示投掷抛物线预览 | | `S` 松开 | 投出钥匙 | | `W` | 传送到扔出去的钥匙位置,并把它捡回来 | @@ -49,9 +49,6 @@ - **重力**:`get_gravity()`,只在 `not is_on_floor()` 时累加到 `velocity.y` - **水平移动**:`Input.get_axis("move_left", "move_right")` 取方向,用 `move_toward()` 做加速 / 减速插值,手感比直接赋值柔和 - **跳跃**:`Input.is_action_just_pressed("jump")` 配合 `is_on_floor()`,因此**只有踩在地面上才能起跳**,天然不会二段跳 - - ⚠️ 目前输入映射里的 `jump` **没有绑定任何按键**(空格被空置了),所以这段代码暂时不会触发。 - 想恢复:`项目 → 项目设置 → 输入映射 → jump → 添加按键 → 空格`,或者把 `project.godot` 里 - `jump` 的 `"events"` 改回 `[Object(InputEventKey, ... "physical_keycode":32 ...)]`。 - **朝向**:根据 `velocity.x` 的正负翻转 `Sprite2D.flip_h` ### ② 瓦片地图 @@ -97,7 +94,7 @@ **技能 B —— 飞行(隐藏技能)**(`player_controller.gd`) -- 按 `F` 切换飞行状态,方向键 ↑ / ↓ 控制升降(`S` 也可以下降),`A` / `D` 平移 +- 按 `F` 切换飞行状态,`空格` / `S` 控制升降(方向键 ↑ / ↓ 也可以),`A` / `D` 平移 - 屏幕上不会有任何提示,它是藏在右上角 **「房★主★有★神★器★」** 按钮里的彩蛋: 点开面板就能看到飞行开关和跳关按钮(键盘 `1` / `2` / `3` 跳关,`Esc` 关闭面板) - 这个面板由自动加载单例 `scripts/cheat_panel.gd` 提供,**三个关卡都有,正式版里也能用** diff --git a/project.godot b/project.godot index fa4e08e..317b7b6 100644 --- a/project.godot +++ b/project.godot @@ -45,7 +45,8 @@ move_right={ } jump={ "deadzone": 0.2, -"events": [] +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null) +] } warp_to_key={ "deadzone": 0.2, diff --git a/scripts/cheat_panel.gd.uid b/scripts/cheat_panel.gd.uid new file mode 100644 index 0000000..e7d7459 --- /dev/null +++ b/scripts/cheat_panel.gd.uid @@ -0,0 +1 @@ +uid://bexl5365w3qgq diff --git a/scripts/player_controller.gd b/scripts/player_controller.gd index fc61e96..36f7718 100644 --- a/scripts/player_controller.gd +++ b/scripts/player_controller.gd @@ -369,10 +369,10 @@ func set_flying(on: bool) -> void: func handle_fly_movement() -> void: - # 跳跃键已经停用了,所以调试飞行改用方向键上下(S 也保留作下降)来控制升降 - var vertical := Input.get_axis("ui_up", "ui_down") - if is_zero_approx(vertical) and Input.is_action_pressed("squat"): - vertical = 1.0 + # 和以前一样:空格(跳跃键)上升、S 下降。方向键上下也顺便能用 + var vertical := Input.get_axis("jump", "squat") + if is_zero_approx(vertical): + vertical = Input.get_axis("ui_up", "ui_down") var direction := Vector2( Input.get_axis("move_left", "move_right"), vertical