- core/: main entry, types, logging, I/O, RNG - asset/: ase loader, cart, save, embed - gfx/: graphics, animation, atlas, fonts, tilemap, transitions - sfx/: audio - script/: lua/fennel runtime, REPL - hal/: platform abstraction (SDL3) - world/: BSP, world, procedural gen - math/: math utilities - game/: GUI, replay - lua/: Lua API modules
58 lines
1,017 B
Fennel
58 lines
1,017 B
Fennel
(local pxl8 (require :pxl8))
|
|
|
|
(var paused false)
|
|
(var gui nil)
|
|
|
|
(fn init []
|
|
(set gui (pxl8.create_gui)))
|
|
|
|
(fn show []
|
|
(set paused true)
|
|
(pxl8.set_relative_mouse_mode false)
|
|
(pxl8.center_cursor))
|
|
|
|
(fn hide []
|
|
(set paused false)
|
|
(pxl8.set_relative_mouse_mode true))
|
|
|
|
(fn toggle []
|
|
(when (not gui) (init))
|
|
(if paused
|
|
(hide)
|
|
(show)))
|
|
|
|
(fn update []
|
|
(when gui
|
|
(let [(mx my) (pxl8.get_mouse_pos)]
|
|
(gui:cursor_move mx my))
|
|
|
|
(when (pxl8.mouse_pressed 1)
|
|
(gui:cursor_down))
|
|
|
|
(when (pxl8.mouse_released 1)
|
|
(gui:cursor_up))))
|
|
|
|
(fn draw []
|
|
(when gui
|
|
(gui:begin_frame)
|
|
|
|
(pxl8.gui_window 200 100 240 140 "pxl8 demo")
|
|
|
|
(when (gui:button 1 215 145 210 32 "Resume")
|
|
(hide))
|
|
|
|
(when (gui:button 2 215 185 210 32 "Quit")
|
|
(pxl8.quit))
|
|
|
|
(if (gui:is_hovering)
|
|
(pxl8.set_cursor :hand)
|
|
(pxl8.set_cursor :arrow))
|
|
|
|
(gui:end_frame)))
|
|
|
|
{:is-paused (fn [] paused)
|
|
:toggle toggle
|
|
:show show
|
|
:hide hide
|
|
:update update
|
|
:draw draw}
|