Removed some logging and commented out code

Also added a couple of comments related to the scene logic
This commit is contained in:
Gordon Pedersen 2023-03-27 14:13:39 +11:00
parent 9a82b55505
commit 2065a6b4d6
5 changed files with 13 additions and 50 deletions

View file

@ -8,10 +8,8 @@ class SettingsMenu < MenuScene
key: :sfx,
kind: :toggle,
on_select: ->(args) do
puts 'toggle sfx'
GameSetting.save_after(args) do |args|
args.state.setting.sfx = !args.state.setting.sfx
puts "sfx = #{args.state.setting.sfx}"
end
end
},

View file

@ -18,7 +18,6 @@ def tick(args)
Input.track_swipe(args) if mobile?
# Scene.send("tick_#{args.state.scene}", args)
args.state.scene_stack.each do |scene|
scene.tick(args) if scene.tick_in_background || scene == args.state.scene_stack.last
end

View file

@ -49,15 +49,11 @@ module Music
queue.each do |channel, value|
unless value.empty?
if args.audio["MUSIC_CHANNEL_#{channel}"]
puts "THERE'S MUSIC CURRENTLY PLAYING #{args.audio["MUSIC_CHANNEL_#{channel}"]}"
if args.audio["MUSIC_CHANNEL_#{channel}"].looping
puts "CANCEL THE LOOP ON CURRENT MUSIC"
args.audio["MUSIC_CHANNEL_#{channel}"].looping = false
end
else
puts "PLAY THAT FUNKY MUSIC! #{value}"
value.shift.play_music(args, { channel: channel, gain: args.state.setting.music ? 0.8 : 0.0 })
puts "Now, the queue is #{value}"
end
end
end

View file

@ -7,8 +7,8 @@
# SceneInstance
#
# The main `#tick` of the game handles delegating to the current scene based on
# the `args.state.scene` value, which is a symbol of the current scene, ex:
# `:gameplay`
# the `args.state.scene_stack` value, which contains the current scene, as well
# as scenes that can be "popped" back to.
module Scene
class << self
# Change the current scene, and optionally reset the scene that's begin
@ -19,15 +19,21 @@ module Scene
args.state.scene_stack ||= []
# if we're here /not/ from push or pop, clear the scene stack
args.state.scene_stack.clear unless push_or_pop
args.state.scene_stack.push(scene) if args.state.scene_stack.empty?
scene.reset(args) if reset
# if `scene` is not a `SceneInstance`, it's probably a symbol representing
# the scene we're switching to, so go get it.
the_scene = scene.is_a?(SceneInstance) ? scene : SCENES[scene].new(args)
# if the stack is empty (e.g. we just cleared it), then push this scene
args.state.scene_stack.push(the_scene) if args.state.scene_stack.empty?
# if we asked to reset the scene, then do so.
the_scene.reset(args) if reset
args.state.scene = scene
raise FinishTick, 'finish tick early'
end
# Change the current scene and push the previous scene onto the stack
# Change the current scene by pushing it onto the scene stack
def push(args, scene, reset: false)
args.state.scene_stack ||= []
the_scene = scene.is_a?(SceneInstance) ? scene : SCENES[scene].new(args)

View file

@ -24,39 +24,3 @@ module Sound
end
end
end
# # play a sound effect. the file in sounds/ must match the key name. ex:
# # play_sfx(args, :select)
# def play_sfx(args, key)
# if args.state.setting.sfx
# args.outputs.sounds << "sounds/#{key}.wav"
# end
# end
# # play the specified music track, the key must correspond to the
# # `sounds/#{key}.ogg` file naming scheme.
# def play_music(args, key)
# args.audio[:music] = { input: "sounds/#{key}.ogg", looping: true, }
# set_music_vol(args)
# end
# # sets the music vol based on whether or not music is enabled or disabled
# def set_music_vol(args)
# vol = args.state.setting.music ? 0.8 : 0.0
# args.audio[:music]&.gain = vol
# end
# # pause the currently playing music track
# def pause_music(args)
# args.audio[:music].paused = true
# end
# # pause the current music track
# def resume_music(args)
# args.audio[:music].paused = false
# end
# # stop the currently playing music track
# def stop_music(args)
# args.audio.delete(:music)
# end