implement audio playing
This commit is contained in:
12
menu.sex
12
menu.sex
@@ -3,6 +3,7 @@
|
||||
(pub import pages)
|
||||
(import main)
|
||||
(import utils)
|
||||
(import audio)
|
||||
|
||||
(pub record menu-state
|
||||
((app-state (* app-state))
|
||||
@@ -23,6 +24,7 @@
|
||||
(= (. state app-state) app-state)
|
||||
(= (. state btn-to-game) 0)
|
||||
(= (. state btn-exit) 0)
|
||||
(audio-play-menu-music)
|
||||
(var img Image (LoadImage "res/img/menu.png"))
|
||||
(ImageResize (& img) WIN-WIDTH WIN-HEIGHT)
|
||||
(= (. state bg) (LoadTextureFromImage img))
|
||||
@@ -52,12 +54,20 @@
|
||||
(EndDrawing))
|
||||
|
||||
(pub fn update-menu ((state (* menu-state))) void
|
||||
(var clicked bool false)
|
||||
(if (== (. state btn-to-game) 1)
|
||||
(do
|
||||
(= (. state btn-to-game) 0)
|
||||
(= clicked true)
|
||||
(.change-page (. state app-state) (sum-type page game))))
|
||||
|
||||
(if (== (. state btn-exit) 1)
|
||||
(do
|
||||
(= (. state btn-exit) 0)
|
||||
(.quit (. state app-state)))))
|
||||
(= clicked true)
|
||||
(.quit (. state app-state))))
|
||||
|
||||
;; Any menu key press is a UI interaction too
|
||||
(var key-pressed bool (!= 0 (GetKeyPressed)))
|
||||
(if (|| clicked key-pressed)
|
||||
(audio-play-menu-click)))
|
||||
|
||||
Reference in New Issue
Block a user