diff options
| author | iamcheeseman <[email protected]> | 2026-03-03 21:18:58 -0500 |
|---|---|---|
| committer | iamcheeseman <[email protected]> | 2026-03-03 21:18:58 -0500 |
| commit | e84dfb90fca869d999297e54538bdfa86e4406aa (patch) | |
| tree | 03c4431f46b146f2c6cfbeeb50e41cf5d2d6b9f7 /src/player.odin | |
| parent | 86f95e0737ba082625c22d40057e66499cbc8ac1 (diff) | |
Fix fall damage
Diffstat (limited to 'src/player.odin')
| -rw-r--r-- | src/player.odin | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/player.odin b/src/player.odin index 592552d..4e1fe90 100644 --- a/src/player.odin +++ b/src/player.odin @@ -221,17 +221,15 @@ _default_state :: proc(dt: f32) { if .Down in new_collisions && .Down not_in collisions { // just landed height := phys.get_position(player.body).y - distance_fallen := height - player.fall_height + if distance_fallen > MAX_SAFE_FALL_HEIGHT { distance_fallen -= MAX_SAFE_FALL_HEIGHT damage := (distance_fallen / MAX_FALL_HEIGHT) * PLAYER_MAX_FALL_DAMAGE + damage = math.clamp(damage, 0, PLAYER_MAX_FALL_DAMAGE) player_take_damage(damage, {0, 0}) } } - - // cam_pos := phys.get_position(player.body) - SCREEN_SIZE * 0.5 - // fw.set_camera_pos(cam_pos) } @(private = "file") @@ -375,6 +373,8 @@ _change_rooms :: proc() { new_pos := pos + diff phys.set_position(player.body, new_pos) + player.fall_height += diff.y + if diff.y > 0 { vel := phys.get_velocity(player.body) vel.y = -PLAYER_JUMP_FORCE |
