From 3d1d31538d30a7f161f9f2b6d5e075ec69d3b860 Mon Sep 17 00:00:00 2001 From: iamcheeseman <[hidden email]> Date: Tue, 3 Feb 2026 22:25:00 -0500 Subject: ditch raylib (icky, and for loser BEGINNERS) --- src/input.odin | 72 ++++++++++++---------------------------------------------- 1 file changed, 15 insertions(+), 57 deletions(-) (limited to 'src/input.odin') diff --git a/src/input.odin b/src/input.odin index 8326564..ee90fcd 100644 --- a/src/input.odin +++ b/src/input.odin @@ -1,67 +1,25 @@ package demonchime -import rl "vendor:raylib" - -KeyboardInput :: union { - rl.KeyboardKey, - rl.MouseButton, -} - -ControllerInput :: union { -} - -Keybind :: struct { - input: KeyboardInput, - pressed: bool, - just_pressed: bool, -} +import fw "fw" actions: struct { - move_left: Keybind, - move_right: Keybind, - jump: Keybind, - dash: Keybind, - shoot: Keybind, - toggle_debug_mode: Keybind, + move_left: fw.Keybind, + move_right: fw.Keybind, + jump: fw.Keybind, + dash: fw.Keybind, + shoot: fw.Keybind, + toggle_debug_mode: fw.Keybind, + toggle_fullscreen: fw.Keybind, + exit: fw.Keybind, } init_keybinds :: proc() { actions.move_left.input = .A actions.move_right.input = .D - actions.jump.input = .SPACE - actions.dash.input = .LEFT_SHIFT - actions.shoot.input = rl.MouseButton.LEFT - actions.toggle_debug_mode.input = .GRAVE -} - -is_keybind_down :: proc(keybind: Keybind) -> bool { - switch val in keybind.input { - case rl.KeyboardKey: - return rl.IsKeyDown(val) - case rl.MouseButton: - return rl.IsMouseButtonDown(val) - } - - assert(false) - return false -} - -is_keybind_just_down :: proc(keybind: Keybind) -> bool { - switch val in keybind.input { - case rl.KeyboardKey: - return rl.IsKeyPressed(val) - case rl.MouseButton: - return rl.IsMouseButtonPressed(val) - } - - assert(false) - return false -} - -get_mouse_pos :: proc() -> (mouse_pos: Vec2) { - mouse_pos = Vec2{f32(rl.GetMouseX()), f32(rl.GetMouseY())} - mouse_pos /= Vec2{f32(rl.GetScreenWidth()), f32(rl.GetScreenHeight())} - mouse_pos *= SCREEN_SIZE - mouse_pos += state.camera.target - return + actions.jump.input = .Space + actions.dash.input = .Left_Shift + actions.shoot.input = fw.Mouse_Button.Left + actions.toggle_debug_mode.input = .T + actions.toggle_fullscreen.input = .F11 + actions.exit.input = .Escape } -- cgit v1.3-2-g0d8e