Commit 9bee4b715ed1261cedca2801e818fcbb89276135

Authored by Marius Hanne
1 parent 6d22799ee9
Exists in master

mute option

Showing 2 changed files with 12 additions and 5 deletions Side-by-side Diff

... ... @@ -19,7 +19,7 @@
19 19  
20 20 include Rubygame
21 21  
22   - attr_reader :screen, :queue, :clock, :objects, :player, :enemies, :level
  22 + attr_reader :screen, :queue, :clock, :objects, :player, :enemies, :level, :opts
23 23 attr_accessor :state
24 24 def initialize opts
25 25 flags = [HWSURFACE, DOUBLEBUF]
... ... @@ -38,6 +38,8 @@
38 38 @level = opts[:level]
39 39 @debug = opts[:debug]
40 40 @state = :ready
  41 + @opts = opts
  42 + Music.autoload_dirs = [ File.join(data_dir, "sound") ]
41 43 end
42 44  
43 45 def draw
... ... @@ -211,6 +213,10 @@
211 213  
212 214 o.on("-f", "--fullscreen", "Fullscreen mode") do
213 215 @opts[:fullscreen] = true
  216 + end
  217 +
  218 + o.on("-m", "--mute", "Disable sounds") do
  219 + @opts[:mute] = true
214 220 end
215 221  
216 222 o.on("-l", "--level LEVEL", "Start at level") do |l|
... ... @@ -12,10 +12,11 @@
12 12 @block = block
13 13 @length = 20
14 14 @zoom = 0.0
15   - Music.autoload_dirs = [ File.join(game.data_dir, "sound") ]
16   - @sound = Music[@opts[:sound]]
17   - @sound.volume = @opts[:volume]
18   - @sound.play(fade_in: 0.0, repeats: 0)
  15 + unless game.opts[:mute]
  16 + @sound = Music[@opts[:sound]]
  17 + @sound.volume = @opts[:volume]
  18 + @sound.play(fade_in: 0.0, repeats: 0)
  19 + end
19 20 end
20 21  
21 22 def blit