godot-genre-platformer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Genre: Platformer

游戏类型:Platformer

Expert blueprint for platformers emphasizing movement feel, level design, and player satisfaction.
平台游戏专家蓝图,重点关注移动手感、关卡设计与玩家体验。

NEVER Do

绝对禁忌

  • NEVER skip coyote time — Without 6-frame grace period after leaving ledge, jumps feel unresponsive. Players blame themselves.
  • NEVER ignore jump buffering — Pressing jump 6 frames before landing should queue jump. Missing this makes controls feel sluggish.
  • NEVER use fixed jump height — Variable jump (hold longer = jump higher) gives players agency. Tap for short hop, hold for full jump.
  • NEVER forget camera smoothing — Instant camera snapping causes motion sickness. Use position_smoothing or lerp for smooth follow.
  • NEVER skip squash/stretch on landing — Landing without visual impact feels weightless. Add 0.1s squash on land for juice.

  • 绝对不要跳过coyote time — 离开平台后如果没有6帧的缓冲时间,跳跃会显得反应迟缓。玩家会归咎于自己操作失误。
  • 绝对不要忽略跳跃缓冲(jump buffering) — 落地前6帧按下跳跃键应触发跳跃指令。缺少这一机制会让操控感变得拖沓。
  • 绝对不要使用固定跳跃高度 — 可变跳跃(按住时间越长跳得越高)能赋予玩家主动权。轻按实现小跳,长按实现满高度跳跃。
  • 绝对不要忘记镜头平滑 — 镜头瞬间切换会引发晕动症。使用position_smoothing或lerp实现平滑跟随。
  • 绝对不要省略落地时的挤压/拉伸效果 — 落地时没有视觉反馈会显得毫无重量感。添加0.1秒的落地挤压效果来增强表现力。

Available Scripts

可用脚本

MANDATORY: Read the appropriate script before implementing the corresponding pattern.
强制要求:在实现对应模式前,请先阅读相应的脚本。

advanced_platformer_controller.gd

advanced_platformer_controller.gd

Complete platformer with coyote time, jump buffer, apex float, and variable gravity. Move_toward-based friction for polished game feel.

完整的平台游戏控制器,包含coyote time、跳跃缓冲、顶点漂浮和可变重力。基于move_toward的摩擦力设计,打造精致的游戏手感。

Core Loop

核心循环

Jump → Navigate Obstacles → Reach Goal → Next Level
跳跃 → 穿越障碍 → 抵达目标 → 进入下一关

Skill Chain

技能链

godot-project-foundations
,
godot-characterbody-2d
,
godot-input-handling
,
animation
,
sound-manager
,
tilemap-setup
,
camera-2d

godot-project-foundations
,
godot-characterbody-2d
,
godot-input-handling
,
animation
,
sound-manager
,
tilemap-setup
,
camera-2d

Movement Feel ("Game Feel")

移动手感("Game Feel")

The most critical aspect of platformers. Players should feel precise, responsive, and in control.
这是平台游戏最关键的部分。玩家应感受到精准、响应迅速且操控自如

Input Responsiveness

输入响应

gdscript
undefined
gdscript
undefined

Instant direction changes - no acceleration on ground

即时方向切换 - 地面移动无加速度

func _physics_process(delta: float) -> void: var input_dir := Input.get_axis("move_left", "move_right")
# Ground movement: instant response
if is_on_floor():
    velocity.x = input_dir * MOVE_SPEED
else:
    # Air movement: slightly reduced control
    velocity.x = move_toward(velocity.x, input_dir * MOVE_SPEED, AIR_ACCEL * delta)
undefined
func _physics_process(delta: float) -> void: var input_dir := Input.get_axis("move_left", "move_right")
# 地面移动:即时响应
if is_on_floor():
    velocity.x = input_dir * MOVE_SPEED
else:
    # 空中移动:操控性略有降低
    velocity.x = move_toward(velocity.x, input_dir * MOVE_SPEED, AIR_ACCEL * delta)
undefined

Coyote Time (Grace Period)

Coyote Time(缓冲时间)

Allow jumping briefly after leaving a platform:
gdscript
var coyote_timer: float = 0.0
const COYOTE_TIME := 0.1  # 100ms grace period

func _physics_process(delta: float) -> void:
    if is_on_floor():
        coyote_timer = COYOTE_TIME
    else:
        coyote_timer = max(0, coyote_timer - delta)
    
    # Can jump if on floor OR within coyote time
    if Input.is_action_just_pressed("jump") and coyote_timer > 0:
        velocity.y = JUMP_VELOCITY
        coyote_timer = 0
允许玩家在离开平台后短暂时间内仍可跳跃:
gdscript
var coyote_timer: float = 0.0
const COYOTE_TIME := 0.1  # 100毫秒缓冲时间

func _physics_process(delta: float) -> void:
    if is_on_floor():
        coyote_timer = COYOTE_TIME
    else:
        coyote_timer = max(0, coyote_timer - delta)
    
    # 当处于地面或缓冲时间内时可跳跃
    if Input.is_action_just_pressed("jump") and coyote_timer > 0:
        velocity.y = JUMP_VELOCITY
        coyote_timer = 0

Jump Buffering

跳跃缓冲(Jump Buffering)

Register jumps pressed slightly before landing:
gdscript
var jump_buffer: float = 0.0
const JUMP_BUFFER_TIME := 0.15

func _physics_process(delta: float) -> void:
    if Input.is_action_just_pressed("jump"):
        jump_buffer = JUMP_BUFFER_TIME
    else:
        jump_buffer = max(0, jump_buffer - delta)
    
    if is_on_floor() and jump_buffer > 0:
        velocity.y = JUMP_VELOCITY
        jump_buffer = 0
记录玩家在落地前短暂时间内按下的跳跃指令:
gdscript
var jump_buffer: float = 0.0
const JUMP_BUFFER_TIME := 0.15

func _physics_process(delta: float) -> void:
    if Input.is_action_just_pressed("jump"):
        jump_buffer = JUMP_BUFFER_TIME
    else:
        jump_buffer = max(0, jump_buffer - delta)
    
    if is_on_floor() and jump_buffer > 0:
        velocity.y = JUMP_VELOCITY
        jump_buffer = 0

Variable Jump Height

可变跳跃高度

gdscript
const JUMP_VELOCITY := -400.0
const JUMP_RELEASE_MULTIPLIER := 0.5

func _physics_process(delta: float) -> void:
    # Cut jump short when button released
    if Input.is_action_just_released("jump") and velocity.y < 0:
        velocity.y *= JUMP_RELEASE_MULTIPLIER
gdscript
const JUMP_VELOCITY := -400.0
const JUMP_RELEASE_MULTIPLIER := 0.5

func _physics_process(delta: float) -> void:
    # 松开跳跃键时提前结束跳跃
    if Input.is_action_just_released("jump") and velocity.y < 0:
        velocity.y *= JUMP_RELEASE_MULTIPLIER

Gravity Tuning

重力调节

gdscript
const GRAVITY := 980.0
const FALL_GRAVITY_MULTIPLIER := 1.5  # Faster falls feel better
const MAX_FALL_SPEED := 600.0

func apply_gravity(delta: float) -> void:
    var grav := GRAVITY
    if velocity.y > 0:  # Falling
        grav *= FALL_GRAVITY_MULTIPLIER
    velocity.y = min(velocity.y + grav * delta, MAX_FALL_SPEED)

gdscript
const GRAVITY := 980.0
const FALL_GRAVITY_MULTIPLIER := 1.5  # 更快的下落速度手感更好
const MAX_FALL_SPEED := 600.0

func apply_gravity(delta: float) -> void:
    var grav := GRAVITY
    if velocity.y > 0:  # 下落时
        grav *= FALL_GRAVITY_MULTIPLIER
    velocity.y = min(velocity.y + grav * delta, MAX_FALL_SPEED)

Level Design Principles

关卡设计原则

The "Teaching Trilogy"

“教学三部曲”

  1. Introduction: Safe environment to learn mechanic
  2. Challenge: Apply mechanic with moderate risk
  3. Twist: Combine with other mechanics or time pressure
  1. 入门引导:在安全环境中学习机制
  2. 挑战环节:在中等风险下应用机制
  3. 创新变体:与其他机制结合或加入时间压力

Visual Language

视觉语言

  • Safe platforms: Distinct color/texture
  • Hazards: Red/orange tints, spikes, glow effects
  • Collectibles: Bright, animated, particle effects
  • Secrets: Subtle environmental hints
  • 安全平台:独特的颜色/纹理
  • 危险区域:红/橙色调、尖刺、发光效果
  • 收集品:明亮、带动画效果、粒子特效
  • 隐藏内容:微妙的环境提示

Flow and Pacing

流程与节奏

Easy → Easy → Medium → CHECKPOINT → Medium → Hard → CHECKPOINT → Boss
简单 → 简单 → 中等 → CHECKPOINT → 中等 → 困难 → CHECKPOINT →  Boss

Camera Design

镜头设计

gdscript
undefined
gdscript
undefined

Look-ahead camera for platformers

平台游戏的前瞻镜头

extends Camera2D
@export var look_ahead_distance := 100.0 @export var look_ahead_speed := 3.0
var target_offset := Vector2.ZERO
func _process(delta: float) -> void: var player_velocity: Vector2 = target.velocity var desired_offset := player_velocity.normalized() * look_ahead_distance target_offset = target_offset.lerp(desired_offset, look_ahead_speed * delta) offset = target_offset

---
extends Camera2D
@export var look_ahead_distance := 100.0 @export var look_ahead_speed := 3.0
var target_offset := Vector2.ZERO
func _process(delta: float) -> void: var player_velocity: Vector2 = target.velocity var desired_offset := player_velocity.normalized() * look_ahead_distance target_offset = target_offset.lerp(desired_offset, look_ahead_speed * delta) offset = target_offset

---

Platformer Sub-Genres

平台游戏子类型

Precision Platformers (Celeste, Super Meat Boy)

精准平台游戏(《蔚蓝》Celeste、《超级食肉男孩》Super Meat Boy)

  • Instant respawn on death
  • Very tight controls (no acceleration)
  • Checkpoints every few seconds of gameplay
  • Death is learning, not punishment
  • 死亡后立即重生
  • 极其精准的操控(无加速度)
  • 每几秒游戏内容就设置一个Checkpoint
  • 死亡是学习过程,而非惩罚

Collectathon (Mario 64, Banjo-Kazooie)

收集型平台游戏(《超级马里奥64》Mario 64、《班卓熊大冒险》Banjo-Kazooie)

  • Large hub worlds with objectives
  • Multiple abilities unlocked over time
  • Backtracking encouraged
  • Stars/collectibles as progression gates
  • 大型枢纽世界,包含多个目标
  • 随进度解锁多种能力
  • 鼓励回溯探索
  • 星星/收集品作为进度闸门

Puzzle Platformers (Limbo, Inside)

解谜平台游戏(《地狱边境》Limbo、《内部》Inside)

  • Slow, deliberate pacing
  • Environmental puzzles
  • Physics-based mechanics
  • Atmospheric storytelling
  • 缓慢、审慎的节奏
  • 环境解谜
  • 基于物理的机制
  • 氛围感叙事

Metroidvania (Hollow Knight)

银河恶魔城(Metroidvania)(《空洞骑士》Hollow Knight)

  • See
    godot-genre-metroidvania
    skill
  • Ability-gated exploration
  • Interconnected world map

  • 参考技能:
    godot-genre-metroidvania
  • 以能力为 gated 的探索
  • 相互连通的世界地图

Common Pitfalls

常见陷阱

PitfallSolution
Floaty jumpsIncrease gravity, especially on descent
Imprecise landingsAdd coyote time and visual landing feedback
Unfair deathsEnsure hazards are clearly visible before encountered
Blind jumpsCamera look-ahead or zoom out during falls
Boring mid-gameIntroduce new mechanics every 2-3 levels

陷阱解决方案
跳跃漂浮感增加重力,尤其是下落时的重力
落地不精准添加coyote time和视觉落地反馈
不公平死亡确保危险区域在玩家遭遇前清晰可见
盲跳下落时使用镜头前瞻或拉远视角
中期游戏乏味每2-3关引入新机制

Polish Checklist

打磨清单

  • Dust godot-particles on land/run
  • Screen shake on heavy landings
  • Squash/stretch animations
  • Sound effects for every action (jump, land, wall-slide)
  • Death and respawn animations
  • Checkpoint visual/audio feedback
  • Accessible difficulty options (assist mode)

  • 落地/奔跑时添加 dust godot-particles 效果
  • 重落地时添加屏幕震动
  • 挤压/拉伸动画
  • 为每个动作添加音效(跳跃、落地、滑墙)
  • 死亡与重生动画
  • Checkpoint 的视觉/音频反馈
  • 无障碍难度选项(辅助模式)

Godot-Specific Tips

Godot 专属技巧

  1. CharacterBody2D vs RigidBody2D: Always use
    CharacterBody2D
    for platformer characters - precise control is essential
  2. Physics tick rate: Consider 120Hz physics for smoother movement
  3. One-way platforms: Use
    set_collision_mask_value()
    or dedicated collision layers
  4. Wall detection: Use
    is_on_wall()
    and
    get_wall_normal()
    for wall jumps

  1. CharacterBody2D vs RigidBody2D:平台游戏角色始终使用
    CharacterBody2D
    ——精准操控至关重要
  2. 物理帧率:考虑使用120Hz物理帧率实现更流畅的移动
  3. 单向平台:使用
    set_collision_mask_value()
    或专用碰撞层
  4. 墙面检测:使用
    is_on_wall()
    get_wall_normal()
    实现墙跳

Example Games for Reference

参考游戏示例

  • Celeste - Perfect game feel, assist mode accessibility
  • Hollow Knight - Combat + platforming integration
  • Super Mario Bros. Wonder - Visual polish and surprises
  • Shovel Knight - Retro mechanics with modern feel
  • Celeste(蔚蓝) - 完美的游戏手感,辅助模式无障碍设计
  • Hollow Knight(空洞骑士) - 战斗与平台玩法的融合
  • Super Mario Bros. Wonder(超级马里奥兄弟:惊奇) - 视觉打磨与惊喜设计
  • Shovel Knight(铲子骑士) - 复古机制结合现代手感

Reference

参考资料

  • Master Skill: godot-master
  • 核心技能:godot-master