ui testing
This commit is contained in:
@@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
libGL
|
libGL
|
||||||
# X11 dependencies for Raylib
|
|
||||||
raylib
|
raylib
|
||||||
|
raygui
|
||||||
xorg.libX11
|
xorg.libX11
|
||||||
xorg.libXcursor
|
xorg.libXcursor
|
||||||
xorg.libXi
|
xorg.libXi
|
||||||
@@ -38,6 +38,7 @@
|
|||||||
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${with pkgs; lib.makeLibraryPath [
|
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${with pkgs; lib.makeLibraryPath [
|
||||||
libGL
|
libGL
|
||||||
raylib
|
raylib
|
||||||
|
raygui
|
||||||
xorg.libX11
|
xorg.libX11
|
||||||
xorg.libXcursor
|
xorg.libXcursor
|
||||||
xorg.libXi
|
xorg.libXi
|
||||||
|
|||||||
BIN
src/assets/pause.jpg
Normal file
BIN
src/assets/pause.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
4
src/gamestate.odin
Normal file
4
src/gamestate.odin
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
GameState :: struct {}
|
||||||
|
|
||||||
@@ -4,6 +4,8 @@ import "core:fmt"
|
|||||||
import "core:strings"
|
import "core:strings"
|
||||||
import "vendor:raylib"
|
import "vendor:raylib"
|
||||||
|
|
||||||
|
delta: f32
|
||||||
|
|
||||||
player: Player
|
player: Player
|
||||||
|
|
||||||
main :: proc() {
|
main :: proc() {
|
||||||
@@ -18,6 +20,8 @@ main :: proc() {
|
|||||||
|
|
||||||
raylib.SetExitKey(nil)
|
raylib.SetExitKey(nil)
|
||||||
|
|
||||||
|
init_pause_menu()
|
||||||
|
|
||||||
init_world()
|
init_world()
|
||||||
defer deinit_world()
|
defer deinit_world()
|
||||||
|
|
||||||
@@ -34,7 +38,7 @@ main :: proc() {
|
|||||||
|
|
||||||
for (!raylib.WindowShouldClose()) {
|
for (!raylib.WindowShouldClose()) {
|
||||||
|
|
||||||
delta := raylib.GetFrameTime()
|
if !is_paused do delta = raylib.GetFrameTime()
|
||||||
|
|
||||||
raylib.BeginDrawing()
|
raylib.BeginDrawing()
|
||||||
raylib.ClearBackground(raylib.BLACK)
|
raylib.ClearBackground(raylib.BLACK)
|
||||||
@@ -47,6 +51,7 @@ main :: proc() {
|
|||||||
|
|
||||||
raylib.EndMode2D()
|
raylib.EndMode2D()
|
||||||
raylib.DrawFPS(20, 20)
|
raylib.DrawFPS(20, 20)
|
||||||
|
draw_pause_menu()
|
||||||
draw_player_grid_debug()
|
draw_player_grid_debug()
|
||||||
raylib.EndDrawing()
|
raylib.EndDrawing()
|
||||||
|
|
||||||
@@ -56,6 +61,9 @@ main :: proc() {
|
|||||||
|
|
||||||
@(private = "file")
|
@(private = "file")
|
||||||
update :: proc(delta: f32) {
|
update :: proc(delta: f32) {
|
||||||
|
process_pause_menu_input()
|
||||||
|
|
||||||
|
if is_paused do return
|
||||||
update_world(delta)
|
update_world(delta)
|
||||||
update_player(&player, delta)
|
update_player(&player, delta)
|
||||||
}
|
}
|
||||||
|
|||||||
42
src/pausemenu.odin
Normal file
42
src/pausemenu.odin
Normal file
@@ -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
|
||||||
|
}
|
||||||
|
|
||||||
@@ -51,9 +51,6 @@ handle_player_camera :: proc(p: ^Player, delta: f32) {
|
|||||||
|
|
||||||
@(private = "file")
|
@(private = "file")
|
||||||
handle_player_input :: proc(p: ^Player, delta: f32) {
|
handle_player_input :: proc(p: ^Player, delta: f32) {
|
||||||
|
|
||||||
if raylib.IsKeyPressed(.ESCAPE) do return
|
|
||||||
|
|
||||||
dir: raylib.Vector2 = {0, 0}
|
dir: raylib.Vector2 = {0, 0}
|
||||||
if raylib.IsKeyDown(.W) do dir.y -= 1
|
if raylib.IsKeyDown(.W) do dir.y -= 1
|
||||||
if raylib.IsKeyDown(.S) do dir.y += 1
|
if raylib.IsKeyDown(.S) do dir.y += 1
|
||||||
|
|||||||
@@ -13,9 +13,6 @@ interactables_layer_grid: Grid
|
|||||||
interactables_tilemap_sheet: TilemapSpritesheet
|
interactables_tilemap_sheet: TilemapSpritesheet
|
||||||
|
|
||||||
init_world :: proc() {
|
init_world :: proc() {
|
||||||
|
|
||||||
// world_base_color = {74, 132, 74, 255}
|
|
||||||
|
|
||||||
ground_tilemap_sheet = load_tilemap_sheet(
|
ground_tilemap_sheet = load_tilemap_sheet(
|
||||||
"assets/tiles/master_tilemap.png",
|
"assets/tiles/master_tilemap.png",
|
||||||
TILEMAP_TILE_SIZE,
|
TILEMAP_TILE_SIZE,
|
||||||
|
|||||||
Reference in New Issue
Block a user