cube-tube/app/scenes/paused.rb

38 lines
945 B
Ruby
Raw Permalink Normal View History

# frozen_string_literal: true
2023-03-08 03:06:29 +00:00
# This is the pause menu, triggered by a button press when the player wants a
# break from gameplay.
class PauseMenu < MenuScene
def initialize(args, opts = {})
menu_options = [
{
key: :resume,
on_select: ->(args) { Scene.pop(args) }
},
{
key: :settings,
2023-04-11 06:26:39 +00:00
on_select: ->(args) { Scene.push(args, :settings, reset: true, reset_on_pop: true) }
},
{
key: :return_to_main_menu,
2023-04-11 06:26:39 +00:00
on_select: ->(args) { Scene.switch(args, :main_menu, reset: true) }
}
]
2023-03-08 03:06:29 +00:00
if args.gtk.platform?(:desktop)
menu_options << {
key: :quit,
on_select: ->(args) { args.gtk.request_quit }
}
end
2023-03-08 03:06:29 +00:00
2023-04-11 06:26:39 +00:00
super args, opts, :paused, menu_options
end
# called every tick of the game loop
def tick(args)
super
Music.pause(args) unless Music.stopped?(args) || Music.paused?(args)
2023-03-08 03:06:29 +00:00
end
end