52 lines
915 B
Text
52 lines
915 B
Text
|
|
(local pxl8 (require :pxl8))
|
||
|
|
|
||
|
|
(var paused false)
|
||
|
|
|
||
|
|
(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 []
|
||
|
|
(if paused
|
||
|
|
(hide)
|
||
|
|
(show)))
|
||
|
|
|
||
|
|
(fn update []
|
||
|
|
(let [(mx my) (pxl8.get_mouse_pos)]
|
||
|
|
(pxl8.gui_cursor_move mx my))
|
||
|
|
|
||
|
|
(when (pxl8.mouse_pressed 1)
|
||
|
|
(pxl8.gui_cursor_down))
|
||
|
|
|
||
|
|
(when (pxl8.mouse_released 1)
|
||
|
|
(pxl8.gui_cursor_up)))
|
||
|
|
|
||
|
|
(fn draw []
|
||
|
|
(pxl8.gui_begin_frame)
|
||
|
|
|
||
|
|
(pxl8.gui_window 200 100 240 140 "pxl8 demo")
|
||
|
|
|
||
|
|
(when (pxl8.gui_button 1 215 145 210 32 "Resume")
|
||
|
|
(hide))
|
||
|
|
|
||
|
|
(when (pxl8.gui_button 2 215 185 210 32 "Quit")
|
||
|
|
(pxl8.quit))
|
||
|
|
|
||
|
|
(if (pxl8.gui_is_hovering)
|
||
|
|
(pxl8.set_cursor :hand)
|
||
|
|
(pxl8.set_cursor :arrow))
|
||
|
|
|
||
|
|
(pxl8.gui_end_frame))
|
||
|
|
|
||
|
|
{:is-paused (fn [] paused)
|
||
|
|
:toggle toggle
|
||
|
|
:show show
|
||
|
|
:hide hide
|
||
|
|
:update update
|
||
|
|
:draw draw}
|