cube-tube/app/scenes/paused.rb

43 lines
1.1 KiB
Ruby
Raw Normal View History

2023-03-08 03:06:29 +00:00
module Scene
class << self
# scene reached from gameplay when the player needs a break
def tick_paused(args)
draw_bg(args, DARK_YELLOW)
options = [
{
key: :resume,
on_select: -> (args) { Scene.pop(args) }
2023-03-08 03:06:29 +00:00
},
{
key: :settings,
on_select: -> (args) { Scene.push(args, :settings, reset: true) }
2023-03-08 03:06:29 +00:00
},
{
key: :return_to_main_menu,
on_select: -> (args) { Scene.switch(args, :main_menu) }
},
]
if args.gtk.platform?(:desktop)
options << {
key: :quit,
on_select: -> (args) { args.gtk.request_quit }
}
end
Menu.tick(args, :paused, options)
2023-03-23 05:16:35 +00:00
Music.pause(args) unless Music.stopped(args)
2023-03-08 03:06:29 +00:00
if secondary_down?(args.inputs)
2023-03-23 05:16:35 +00:00
Sound.play(args, :select)
2023-03-08 03:06:29 +00:00
options.find { |o| o[:key] == :resume }[:on_select].call(args)
2023-03-08 03:06:29 +00:00
end
args.outputs.labels << label(:paused, x: args.grid.w / 2, y: args.grid.top - 200, align: ALIGN_CENTER, size: SIZE_LG, font: FONT_BOLD)
end
end
end