diff --git a/flake.nix b/flake.nix index 57ae56f..ab6c9f2 100644 --- a/flake.nix +++ b/flake.nix @@ -24,8 +24,8 @@ buildInputs = with pkgs; [ libGL - # X11 dependencies for Raylib raylib + raygui xorg.libX11 xorg.libXcursor xorg.libXi @@ -38,6 +38,7 @@ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${with pkgs; lib.makeLibraryPath [ libGL raylib + raygui xorg.libX11 xorg.libXcursor xorg.libXi diff --git a/src/assets/pause.jpg b/src/assets/pause.jpg new file mode 100644 index 0000000..7688273 Binary files /dev/null and b/src/assets/pause.jpg differ diff --git a/src/gamestate.odin b/src/gamestate.odin new file mode 100644 index 0000000..a0f5439 --- /dev/null +++ b/src/gamestate.odin @@ -0,0 +1,4 @@ +package main + +GameState :: struct {} + diff --git a/src/main.odin b/src/main.odin index 5b4dabf..288963d 100644 --- a/src/main.odin +++ b/src/main.odin @@ -4,6 +4,8 @@ import "core:fmt" import "core:strings" import "vendor:raylib" +delta: f32 + player: Player main :: proc() { @@ -18,6 +20,8 @@ main :: proc() { raylib.SetExitKey(nil) + init_pause_menu() + init_world() defer deinit_world() @@ -34,7 +38,7 @@ main :: proc() { for (!raylib.WindowShouldClose()) { - delta := raylib.GetFrameTime() + if !is_paused do delta = raylib.GetFrameTime() raylib.BeginDrawing() raylib.ClearBackground(raylib.BLACK) @@ -47,6 +51,7 @@ main :: proc() { raylib.EndMode2D() raylib.DrawFPS(20, 20) + draw_pause_menu() draw_player_grid_debug() raylib.EndDrawing() @@ -56,6 +61,9 @@ main :: proc() { @(private = "file") update :: proc(delta: f32) { + process_pause_menu_input() + + if is_paused do return update_world(delta) update_player(&player, delta) } diff --git a/src/pausemenu.odin b/src/pausemenu.odin new file mode 100644 index 0000000..e4f6529 --- /dev/null +++ b/src/pausemenu.odin @@ -0,0 +1,42 @@ +package main + +import "core:fmt" +import rl "vendor:raylib" + +test_pause_tex: rl.Texture2D +test_pause_button_rect: rl.Rectangle + +is_paused := false + +init_pause_menu :: proc() { + test_pause_tex = rl.LoadTexture("./assets/pause.jpg") + test_pause_button_rect = { + x = 200, + y = 200, + width = f32(test_pause_tex.width), + height = f32(test_pause_tex.height), + } +} + +draw_pause_menu :: proc() { + if (is_paused) do rl.DrawTexture(test_pause_tex, 200, 200, rl.WHITE) +} + +process_pause_menu_input :: proc() { + mouse_pos := rl.GetMousePosition() + + if rl.IsKeyPressed(.ESCAPE) do is_paused = !is_paused + + if !is_paused do return + + if (rl.CheckCollisionPointRec(mouse_pos, test_pause_button_rect)) { + if (rl.IsMouseButtonPressed(rl.MouseButton.LEFT)) { + test_pause_click() + } + } +} + +test_pause_click :: proc() { + is_paused = false +} + diff --git a/src/player.odin b/src/player.odin index 855350e..07ddcc0 100644 --- a/src/player.odin +++ b/src/player.odin @@ -51,9 +51,6 @@ handle_player_camera :: proc(p: ^Player, delta: f32) { @(private = "file") handle_player_input :: proc(p: ^Player, delta: f32) { - - if raylib.IsKeyPressed(.ESCAPE) do return - dir: raylib.Vector2 = {0, 0} if raylib.IsKeyDown(.W) do dir.y -= 1 if raylib.IsKeyDown(.S) do dir.y += 1 diff --git a/src/world.odin b/src/world.odin index 703f54a..d52177f 100644 --- a/src/world.odin +++ b/src/world.odin @@ -13,9 +13,6 @@ interactables_layer_grid: Grid interactables_tilemap_sheet: TilemapSpritesheet init_world :: proc() { - - // world_base_color = {74, 132, 74, 255} - ground_tilemap_sheet = load_tilemap_sheet( "assets/tiles/master_tilemap.png", TILEMAP_TILE_SIZE,