Files
sijcdu 9dffacd938 Initial commit: Godot 4.7 pixel platformer prototype
Player: move/jump (Space), test flight (F, debug builds only). Key: pickup, hold S to aim with live trajectory preview, release to throw, W to warp to the thrown key. Spring bounce. Spikes deal damage. 3-heart health, Z consumes a heal item for +1 heart and a 5s shield. HUD with hearts and item count. Death screen with fade-to-black and restart. Hidden passages. Assets: Kenney Pixel Platformer (CC0).
2026-10-07 20:32:42 +08:00

24 lines
848 B
GDScript

extends Area2D
## 弹起角色时给它的向上速度(负值 = 向上)。玩家正常跳跃是 -190,这里给约 1.6 倍。
@export var bounce_velocity: float = -300.0
## 角色的竖直速度要 >= 这个值才弹(正在往上冲的时候不弹,免得把人往下拍)
@export var min_downward_speed: float = -1.0
## 角色的中心必须比弹簧中心高出这么多像素,才算"从上面踩下来";从侧面撞过去不弹
@export var top_zone_offset: float = 4.0
func _ready() -> void:
body_entered.connect(_on_body_entered)
func _on_body_entered(body: Node2D) -> void:
var character := body as CharacterBody2D
if character == null:
return
if character.velocity.y < min_downward_speed:
return
if character.global_position.y > global_position.y - top_zone_offset:
return
character.velocity.y = bounce_velocity