aboutsummaryrefslogtreecommitdiff
path: root/src/player.odin
diff options
context:
space:
mode:
authoriamcheeseman <[hidden email]>2026-02-15 15:50:10 -0500
committeriamcheeseman <[hidden email]>2026-02-15 15:50:10 -0500
commitf45cafdf46455768985e3d3a118bbca1839e937f (patch)
tree9da244f6dcc7aad6b12929aa5b10b35e6aa220fc /src/player.odin
parentcab0d6e99d96f621e6efcf1ed6b5537cf122ad96 (diff)
fix lame prop spawning bug
Diffstat (limited to 'src/player.odin')
-rw-r--r--src/player.odin20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/player.odin b/src/player.odin
index 7a0ee45..353254b 100644
--- a/src/player.odin
+++ b/src/player.odin
@@ -32,6 +32,7 @@ player: struct {
state: Player_State,
outside_room: bool,
has_double_jumped: bool,
+ fall_height: f32,
owns_double_jump: bool,
owns_dash: bool,
@@ -136,6 +137,7 @@ _default_state :: proc(dt: f32) {
if .Down in collisions {
player.coyote_time = PLAYER_COYOTE_TIME
player.has_double_jumped = false
+ player.fall_height = pos.y
} else {
switch vel.y {
case -math.INF_F32..<-50:
@@ -149,6 +151,8 @@ _default_state :: proc(dt: f32) {
if _can_wallslide(input) {
_enter_wall_slide()
}
+
+ player.fall_height = min(pos.y, player.fall_height)
}
rel_mouse_pos := fw.get_mouse_pos() - pos
@@ -202,6 +206,16 @@ _default_state :: proc(dt: f32) {
phys.update_body(player.body)
+ new_collisions := phys.get_collisions(player.body)
+
+ if .Down in new_collisions && .Down not_in collisions {
+ // just landed
+ height := phys.get_position(player.body).y
+ if height - player.fall_height > 16 * 16 {
+ log.info("DEAD")
+ }
+ }
+
// cam_pos := phys.get_position(player.body) - SCREEN_SIZE * 0.5
// fw.set_camera_pos(cam_pos)
}
@@ -241,6 +255,9 @@ _exit_dash :: proc() {
vel := phys.get_velocity(player.body)
phys.set_velocity(player.body, vel / 2)
+
+ pos := phys.get_position(player.body)
+ player.fall_height = pos.y
}
@(private = "file")
@@ -278,6 +295,9 @@ _wall_slide_state :: proc(dt: f32) {
if fw.is_keybind_just_down(actions.jump) {
_enter_wall_jump()
}
+
+ pos := phys.get_position(player.body)
+ player.fall_height = pos.y
}
@(private = "file")