Add sounds

This commit is contained in:
Pyrex 2024-02-11 20:54:01 -08:00
parent bb2cfdd6af
commit 4747e297b4
10 changed files with 70 additions and 11 deletions

View File

@ -93,8 +93,10 @@ function board:get_completion_level()
end
function board:undo()
if (not self.watcher:intercept("undo")) return
if (self.checkpoint) self.checkpoint:apply(self)
if (not self.checkpoint) return
if (not self.watcher:intercept("undo")) sounds:dire() return
sounds:menu()
self.checkpoint:apply(self)
self.checkpoint=nil
end

View File

@ -55,7 +55,7 @@ function board:_animate_move_card(card,on_end,start_x,start_y,compute_end)
if (frame==0) end_x,end_y=compute_end()
frame+=1
progress=frame/7
if (progress>=1.0) on_end() return false
if (progress>=1.0) sounds:deal_card() on_end() return false
return true
end
function anim_obj:draw()

View File

@ -36,18 +36,21 @@ function cursor:toggle_grab()
local acc,src,tar=self:acceptance_state()
local slot=self:hover_slot()
if acc==acceptance_state.not_grabbed then
if (not self.board.watcher:intercept("grab",slot)) return
if (not self.board.watcher:intercept("grab",slot)) sounds:dire() return
if (self.board.slots[slot]:peek()) self.grabbed=slot
sounds:menu()
elseif acc==acceptance_state.would_accept then
if (not self.board.watcher:intercept("drop",slot)) return
if (not self.board.watcher:intercept("drop",slot)) sounds:dire() return
self.board:pre_move(src:peek())
local card=src:pop()
tar:add(card)
self.grabbed=nil
self.board:on_move(card)
sounds:menu()
elseif acc==acceptance_state.no_move or acc==acceptance_state.would_not_accept then
if (not self.board.watcher:intercept("cancel")) return
if (not self.board.watcher:intercept("cancel")) sounds:dire() return
self.grabbed=nil
sounds:menu()
else
assert(false,"invalid acceptance state")
end

38
main.p8
View File

@ -20,6 +20,7 @@ __lua__
#include progression.lua
#include seed_constants.lua
#include seeds.lua
#include sounds.lua
#include state_archaeology.lua
#include state_excavate_menu.lua
#include state_manager.lua
@ -230,6 +231,43 @@ __sfx__
a51300003051030510305103051030510305103051030510305103051030510305103051030510305103051524500245002450024500245002450024500245002450024500245002450024500245002450024500
011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
930a00003766437625000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
954a00002b66518000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
010400000c25512255232550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0108000013335113000c3000c3050c305000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__music__
01 00551544
00 01551544

13
sounds.lua Normal file
View File

@ -0,0 +1,13 @@
sounds={}
function sounds:menu()
sfx(63,3)
end
function sounds:deal_card()
sfx(60,3)
end
function sounds:dire()
sfx(62,3)
end
function sounds:win()
sfx(61,3)
end

View File

@ -43,8 +43,8 @@ function state_archaeology:update()
local vel=0
if (btnp(0)) vel-=1
if (btnp(1)) vel+=1
if (btnp(5)) self.done=true
if (vel!=0) self:select_book((self.selection+vel-1)%self.n_holy_books+1)
if (btnp(5)) sounds:menu() self.done=true
if (vel!=0) sounds:menu() self:select_book((self.selection+vel-1)%self.n_holy_books+1)
end
function state_archaeology:draw()
local fullw,fullh=measure_text(self.full_text)

View File

@ -35,7 +35,7 @@ end
function state_menu:update()
self.frame+=1
self.frame%=1024
if (btnp(1) or btnp(4)) self.options[self.selection]:cb()
if (btnp(1) or btnp(4)) sounds:menu() self.options[self.selection]:cb()
local vel=0
if (btnp(2)) vel-=1

View File

@ -23,6 +23,7 @@ function state_reset_menu:update()
run()
end
if self.code[self.code_i]==o then
sounds:dire()
self.code_i+=1
if (self.code_i>#self.code) completion_tracker:reset()
else

View File

@ -2,6 +2,7 @@ state_wonironman=klass()
function state_wonironman:init()
end
function state_wonironman:enter()
sounds:win()
completion_tracker:incr_metascore()
end
function state_wonironman:exit(new_top) end
@ -10,7 +11,7 @@ function state_wonironman:reenter() end
function state_wonironman:suspend() end
function state_wonironman:update()
if (btnp(4)) self.done=true
if (btnp(4)) sounds:menu() self.done=true
end
function state_wonironman:draw()
cls(13)

View File

@ -9,6 +9,7 @@ function state_wonround:init(board)
end
seen_tip_this_session=false
function state_wonround:enter()
sounds:win()
completion_tracker:mark_seen(self.verse_id)
completion_tracker:advance_completion_level(self.board:get_completion_level())
self.has_tip = not seen_tip_this_session
@ -26,7 +27,7 @@ function state_wonround:update()
self.board:set_restart_progress(self.progress)
if (self.progress<1.0) return
if (btnp(4)) self.done=true
if (btnp(4)) sounds:menu() self.done=true
end
function state_wonround:draw()
cls(13)