implement audio playing

This commit is contained in:
2026-11-08 20:20:10 +03:00
parent 935b30aae0
commit 0816e8e4ec
5 changed files with 104 additions and 4 deletions

View File

@@ -4,6 +4,7 @@
(pub import pages)
(import main)
(import utils)
(import audio)
(pub import tmx)
(define MAP-FILE "res/tilemaps/SaveAss.tmx")
@@ -108,6 +109,7 @@
(pub fn mk-game ((app-state (* app-state))) page
(var state _ (mem-alloc game-state))
(= (. state app-state) app-state)
(audio-play-game-music)
(var map (* tmx-map) (load-tmx MAP-FILE))
(= (. state map) map)
@@ -310,7 +312,8 @@
(do
(= (. state fishing-minigame-active) false)
(= (. state bobber-y) 0.0f)
(= (. state bobber-vy) 0.0f))))
(= (. state bobber-vy) 0.0f)
(audio-play-game-music))))
(pub fn update-game ((state (* game-state))) void
(if (== (. state map) NULL)
@@ -348,13 +351,17 @@
(.update (& (. state cam)) state)
;; If we're near the fishing spot, show the tip and arm the fishing game
(var was-near bool (. state near-fishing-spot))
(= (. state near-fishing-spot) false)
(if (!= NULL (tmx-object-at-point (. state fishing-spots) (player-center state)))
(do
(= (. state near-fishing-spot) true)
(if (! was-near)
(audio-play-fishing-spot))
(if (IsKeyReleased KEY-X)
(do
(= (. state fishing-minigame-active) true)
(= (. state bobber-y) 0.0f)
(= (. state bobber-vy) 0.0f)
(audio-play-fishing-music)
(TraceLog LOG-INFO "Starting fishing minigame!"))))))