add new maps, persistent storage, music toggle button
This commit is contained in:
22
menu.sex
22
menu.sex
@@ -9,6 +9,7 @@
|
||||
((app-state (* app-state))
|
||||
(bg Texture2D)
|
||||
(btn-to-game int)
|
||||
(btn-toggle-music int)
|
||||
(btn-exit int)))
|
||||
|
||||
(define WIN-WIDTH 1440)
|
||||
@@ -17,10 +18,15 @@
|
||||
(define BTN-WIDTH 320.0)
|
||||
(define BTN-HEIGHT 72.0)
|
||||
|
||||
(define MUSIC-BTN-WIDTH 240.0)
|
||||
(define MUSIC-BTN-HEIGHT 60.0)
|
||||
(define MUSIC-BTN-MARGIN 40.0)
|
||||
|
||||
(pub fn mk-menu ((app-state (* app-state))) page
|
||||
(var state _ (mem-alloc menu-state))
|
||||
(= (. state app-state) app-state)
|
||||
(= (. state btn-to-game) 0)
|
||||
(= (. state btn-toggle-music) 0)
|
||||
(= (. state btn-exit) 0)
|
||||
(audio-play-menu-music)
|
||||
(var img Image (LoadImage "res/img/menu.png"))
|
||||
@@ -49,10 +55,26 @@
|
||||
BTN-WIDTH
|
||||
BTN-HEIGHT) "Quit"))
|
||||
|
||||
(var music-label (* const char) "Music: On")
|
||||
(if (! (audio-music-enabled))
|
||||
(= music-label "Music: Off"))
|
||||
(= (. state btn-toggle-music)
|
||||
(GuiButton #(Rectangle :
|
||||
(- WIN-WIDTH (+ MUSIC-BTN-MARGIN MUSIC-BTN-WIDTH))
|
||||
MUSIC-BTN-MARGIN
|
||||
MUSIC-BTN-WIDTH
|
||||
MUSIC-BTN-HEIGHT) music-label))
|
||||
|
||||
(EndDrawing))
|
||||
|
||||
(pub fn update-menu ((state (* menu-state))) void
|
||||
(var clicked bool false)
|
||||
(if (== (. state btn-toggle-music) 1)
|
||||
(do
|
||||
(= (. state btn-toggle-music) 0)
|
||||
(= clicked true)
|
||||
(audio-toggle-music)))
|
||||
|
||||
(if (== (. state btn-to-game) 1)
|
||||
(do
|
||||
(= (. state btn-to-game) 0)
|
||||
|
||||
Reference in New Issue
Block a user