From afb58a61abd0e8114a090ab0ad664d59c10dd4b1 Mon Sep 17 00:00:00 2001 From: iamcheeseman <[hidden email]> Date: Tue, 13 Jan 2026 00:01:44 -0500 Subject: formatter --- src/player.odin | 58 ++++++++++++++++++++++++--------------------------------- 1 file changed, 24 insertions(+), 34 deletions(-) (limited to 'src/player.odin') diff --git a/src/player.odin b/src/player.odin index e7fd214..71b015b 100644 --- a/src/player.odin +++ b/src/player.odin @@ -28,32 +28,26 @@ Player_State :: enum { player: struct { body_handle: phys.Body_Handle, sprite: Sprite, - jump_buffer: f32, coyote_time: f32, - dash_cooldown: f32, dash_timer: f32, - state: Player_State, - outside_room: bool, has_double_jumped: bool, } init_player :: proc() { - handle, body := phys.make_body( - phys.Rect{{-4, 17}, {8, 16}}, - ) + handle, body := phys.make_body(phys.Rect{{-4, 17}, {8, 16}}) player.body_handle = handle phys.set_body_position(handle, Vec2{50, 100}) init_sprite(&player.sprite, .PLAYER) - player.sprite.offset = Vec2{ + player.sprite.offset = Vec2 { math.floor(f32(player.sprite.width / 2)), - -f32(player.sprite.height) + -f32(player.sprite.height), } } @@ -63,7 +57,7 @@ delete_player :: proc() { destroy_sprite(player.sprite) } -@(private="file") +@(private = "file") get_input_dir :: proc() -> f32 { input: f32 @@ -77,7 +71,7 @@ get_input_dir :: proc() -> f32 { return input } -@(private="file") +@(private = "file") default_state :: proc(dt: f32) { input := get_input_dir() @@ -104,12 +98,12 @@ default_state :: proc(dt: f32) { player.has_double_jumped = false } else { switch body.vel.y { - case -math.INF_F32..<-50: - set_sprite_active_tag(&player.sprite, "jump_up") - case 50.. width \ - || body.pos.y < 0 || body.pos.y > height { - prev_room_pos := Vec2{ - f32(current_room.x), - f32(current_room.y), - } + if body.pos.x < 0 || + body.pos.x > width || + body.pos.y < 0 || + body.pos.y > height { + prev_room_pos := Vec2{f32(current_room.x), f32(current_room.y)} changed := open_room_at({i32(body.pos.x), i32(body.pos.y)}) if changed { - new_room_pos := Vec2{ - f32(current_room.x), - f32(current_room.y), - } + new_room_pos := Vec2{f32(current_room.x), f32(current_room.y)} diff := prev_room_pos - new_room_pos new_pos := body.pos + diff - {0, 0} -- cgit v1.3-2-g0d8e