class Core::Song

cache system borks inheritance, so we need to wrap a Gosu::Song instance

Attributes

file[R]

Public Class Methods

new(file) click to toggle source
# File lib/song.rb, line 7
def initialize(file)
  @file = file
  if @@cache[file]
    @song = @@cache[file]
    return
  end
  begin
    @song = Gosu::Song.new(Core.window, "#{Core::LIBRARY_PATH}/music/#{file}.mp3")
    @@cache.store(file, @song)
  rescue RuntimeError
    puts("ERROR: Failed to open music #{file}")
    return
  end
end

Public Instance Methods

pause() click to toggle source
# File lib/song.rb, line 27
def pause
  @song.pause
end
play(loop=true) click to toggle source
# File lib/song.rb, line 36
def play(loop=true)
  @song.volume = Core.config[:volume]+1.0 # FIXME no effect?
  @song.play(loop)
end
song() click to toggle source
# File lib/song.rb, line 21
def song
  return @song
end
stop() click to toggle source
# File lib/song.rb, line 24
def stop
  @song.stop
end
volume() click to toggle source
# File lib/song.rb, line 30
def volume
  return @song.volume
end
volume=(vol) click to toggle source
# File lib/song.rb, line 33
def volume=(vol)
  @song.volume = vol
end