diff --git a/app/scenes/cube_tube.rb b/app/scenes/cube_tube.rb index 187c734..9b43d97 100644 --- a/app/scenes/cube_tube.rb +++ b/app/scenes/cube_tube.rb @@ -269,6 +269,7 @@ class CubeTubeGame < GameplayScene Sound.play(@args, :drop) if current_piece_colliding @gameover = true + Sound.play(@args, :train_stop2) Music.stop(@args) end else diff --git a/app/scenes/intro.rb b/app/scenes/intro.rb index 407f6b9..b348a90 100644 --- a/app/scenes/intro.rb +++ b/app/scenes/intro.rb @@ -5,7 +5,7 @@ class Intro < GameplayScene def initialize(args, opts = {}) super - @train_duration = 200 + @train_duration = 190 @train_spline = [ [1.0, 0.25, 0, 0] ] @@ -26,26 +26,34 @@ class Intro < GameplayScene Scene.switch(args, :cube_tube, reset: true) end - @start ||= args.state.tick_count + now = args.state.tick_count + + if @start.zero? || @start.nil? + @start = now + Sound.play(args, :train_stop) + end + case @state when 0 - if (args.state.tick_count - @start) > 60 - @train_start = args.state.tick_count + if (now - @start) > 60 + @train_start = now @state += 1 end when 1 - @train_pos = 1280 * args.easing.ease_spline(@train_start, args.state.tick_count, @train_duration, @train_spline) + @train_pos = 1280 * args.easing.ease_spline(@train_start, now, @train_duration, @train_spline) if @train_pos <= 0 @state += 1 - @wait_start = args.state.tick_count + @wait_start = now + Sound.play(args, :chime) end when 2 - if (args.state.tick_count - @wait_start) > 60 - @leave_start = args.state.tick_count + if (now - @wait_start) > 60 + @leave_start = now @state += 1 + Sound.play(args, :train_leave) end when 3 - ease = args.easing.ease_spline(@leave_start, args.state.tick_count, @leave_duration, @leave_spline) + ease = args.easing.ease_spline(@leave_start, now, @leave_duration, @leave_spline) @station_pos = @full_station_start_w * ease @screen_on = true if ease > 0.75 @@ -64,7 +72,7 @@ class Intro < GameplayScene if @screen_on screen_s = - case (args.state.tick_count % 32) + case (now % 32) when 0..7 then :screen_s1 when 8..15 then :screen_s2 when 16..23 then :screen_s3 diff --git a/app/scenes/main_menu.rb b/app/scenes/main_menu.rb index 5f17bab..aede4c7 100644 --- a/app/scenes/main_menu.rb +++ b/app/scenes/main_menu.rb @@ -30,6 +30,16 @@ class MainMenu < MenuScene # actual menu logic is handled by the MenuScene super class super + Music.play(args, :ambience) if args.state.setting.music && Music.stopped(args) + @next_announcement ||= 0 + if @next_announcement <= args.state.tick_count + next_sec = random(20..50) + @next_announcement = args.state.tick_count + (next_sec * 60) + sound = :"ambient#{random(1..6)}" + puts sound, Sound.for(sound).input + Sound.play(args, sound) + end + # additionally draw some labels with information about the game labels = [] labels << label( diff --git a/app/util/util.rb b/app/util/util.rb index b2b1e51..a2cbcdc 100644 --- a/app/util/util.rb +++ b/app/util/util.rb @@ -3,9 +3,19 @@ # returns random val between min & max, inclusive # needs integers, use rand if you don't need min/max and don't care much -def random(min, max) - min = Integer(min) - max = Integer(max) +def random(a, b = nil) + min = 0 + max = 1 + if a.is_a?(Range) + min = a.begin + max = a.last(1)[0] + elsif a.is_a?(Numeric) && b.is_a?(Numeric) + min = Integer(a) + max = Integer(b) + else + min = 0 + max = a + end rand((max + 1) - min) + min end diff --git a/music/_list.rb b/music/_list.rb index ec70bde..010ee48 100644 --- a/music/_list.rb +++ b/music/_list.rb @@ -2,7 +2,8 @@ module Music MUSIC = { - music1: SoundInstance.new({ path: 'music/music1.ogg', looping: true }), - music2: SoundInstance.new({ path: 'music/music2.ogg', looping: true }) + music1: SoundInstance.new({ path: 'music/music1.ogg', looping: true }), + music2: SoundInstance.new({ path: 'music/music2.ogg', looping: true }), + ambience: SoundInstance.new({ path: 'music/ambience1.ogg', looping: true }) } end diff --git a/music/ambience1.ogg b/music/ambience1.ogg new file mode 100644 index 0000000..69eaeb1 Binary files /dev/null and b/music/ambience1.ogg differ diff --git a/sounds/_list.rb b/sounds/_list.rb index eb83cdd..2307981 100644 --- a/sounds/_list.rb +++ b/sounds/_list.rb @@ -2,12 +2,22 @@ module Sound SOUNDS = { - menu: SoundInstance.new({ path: 'sounds/menu.wav' }), - select: SoundInstance.new({ path: 'sounds/select.wav' }), - clear: SoundInstance.new({ path: 'sounds/clear.wav' }), - drop: SoundInstance.new({ path: 'sounds/drop.wav' }), - move: SoundInstance.new({ path: 'sounds/move.wav' }), - move_deny: SoundInstance.new({ path: 'sounds/move_deny.wav' }), - rotate: SoundInstance.new({ path: 'sounds/rotate.wav' }) + menu: SoundInstance.new({ path: 'sounds/menu.wav' }), + select: SoundInstance.new({ path: 'sounds/select.wav' }), + clear: SoundInstance.new({ path: 'sounds/clear.wav' }), + drop: SoundInstance.new({ path: 'sounds/drop.wav' }), + move: SoundInstance.new({ path: 'sounds/move.wav' }), + move_deny: SoundInstance.new({ path: 'sounds/move_deny.wav' }), + rotate: SoundInstance.new({ path: 'sounds/rotate.wav' }), + train_stop: SoundInstance.new({ path: 'sounds/train_stop.wav' }), + train_stop2: SoundInstance.new({ path: 'sounds/train_stop2.wav' }), + train_leave: SoundInstance.new({ path: 'sounds/train_leave.wav' }), + chime: SoundInstance.new({ path: 'sounds/please_stand_clear.wav' }), + ambient1: SoundInstance.new({ path: 'sounds/announcement.ogg', loop: false }), + ambient2: SoundInstance.new({ path: 'sounds/announcement2.ogg', loop: false }), + ambient3: SoundInstance.new({ path: 'sounds/announcement3.ogg', loop: false }), + ambient4: SoundInstance.new({ path: 'sounds/announcements.ogg', loop: false }), + ambient5: SoundInstance.new({ path: 'sounds/train_pass.ogg', loop: false }), + ambient6: SoundInstance.new({ path: 'sounds/train_pass2.ogg', loop: false }) } end \ No newline at end of file diff --git a/sounds/announcement.ogg b/sounds/announcement.ogg new file mode 100644 index 0000000..a39a0f4 Binary files /dev/null and b/sounds/announcement.ogg differ diff --git a/sounds/announcement2.ogg b/sounds/announcement2.ogg new file mode 100644 index 0000000..1798d58 Binary files /dev/null and b/sounds/announcement2.ogg differ diff --git a/sounds/announcement3.ogg b/sounds/announcement3.ogg new file mode 100644 index 0000000..cfba8cc Binary files /dev/null and b/sounds/announcement3.ogg differ diff --git a/sounds/announcements.ogg b/sounds/announcements.ogg new file mode 100644 index 0000000..c186755 Binary files /dev/null and b/sounds/announcements.ogg differ diff --git a/sounds/please_stand_clear.wav b/sounds/please_stand_clear.wav new file mode 100644 index 0000000..0b6f572 Binary files /dev/null and b/sounds/please_stand_clear.wav differ diff --git a/sounds/train_leave.wav b/sounds/train_leave.wav new file mode 100644 index 0000000..008037a Binary files /dev/null and b/sounds/train_leave.wav differ diff --git a/sounds/train_pass.ogg b/sounds/train_pass.ogg new file mode 100644 index 0000000..bf2bd31 Binary files /dev/null and b/sounds/train_pass.ogg differ diff --git a/sounds/train_pass2.ogg b/sounds/train_pass2.ogg new file mode 100644 index 0000000..e083aaa Binary files /dev/null and b/sounds/train_pass2.ogg differ diff --git a/sounds/train_stop.wav b/sounds/train_stop.wav new file mode 100644 index 0000000..f204ed8 Binary files /dev/null and b/sounds/train_stop.wav differ diff --git a/sounds/train_stop2.wav b/sounds/train_stop2.wav new file mode 100644 index 0000000..6094801 Binary files /dev/null and b/sounds/train_stop2.wav differ diff --git a/wip-assets/sounds/ambience1.ogg b/wip-assets/sounds/ambience1.ogg new file mode 100644 index 0000000..82ee67b Binary files /dev/null and b/wip-assets/sounds/ambience1.ogg differ diff --git a/wip-assets/sounds/announcement.ogg b/wip-assets/sounds/announcement.ogg new file mode 100644 index 0000000..fcb2484 Binary files /dev/null and b/wip-assets/sounds/announcement.ogg differ diff --git a/wip-assets/sounds/announcement2.ogg b/wip-assets/sounds/announcement2.ogg new file mode 100644 index 0000000..494533d Binary files /dev/null and b/wip-assets/sounds/announcement2.ogg differ diff --git a/wip-assets/sounds/announcement3.ogg b/wip-assets/sounds/announcement3.ogg new file mode 100644 index 0000000..d74afe0 Binary files /dev/null and b/wip-assets/sounds/announcement3.ogg differ diff --git a/wip-assets/sounds/announcements.ogg b/wip-assets/sounds/announcements.ogg new file mode 100644 index 0000000..1414360 Binary files /dev/null and b/wip-assets/sounds/announcements.ogg differ diff --git a/wip-assets/sounds/chime.wav b/wip-assets/sounds/chime.wav new file mode 100644 index 0000000..7dc54d3 Binary files /dev/null and b/wip-assets/sounds/chime.wav differ diff --git a/wip-assets/sprites/tunnel-half.vox b/wip-assets/sprites/tunnel-half.vox index d09b6ca..5367eab 100644 Binary files a/wip-assets/sprites/tunnel-half.vox and b/wip-assets/sprites/tunnel-half.vox differ