require 'gosu'
class GameWindow < Gosu::Window
def initialize
super 1024, 768, false
@res = Resources.new(self, "resources")
@state = MainMenuState.new(self, @res)
end
def button_down(id)
if id == Gosu::KbEscape
#uncomment for the workaround
#@res.music.each do |title, song|
# song.stop
#end
close
end
end
end
class Resources
attr_accessor :music
def initialize(window, directory)
@music = {}
Dir.glob("#{directory}/music/*.ogg").each do |filename|
base = File.basename(filename, ".ogg")
@music[base] = Gosu::Song.new(window, filename)
end
end
end
class MainMenuState
def initialize(window, res)
@music = res.music["title_screen"]
@music.play
end
end
window = GameWindow.new
window.show
require 'gosu'
class GameWindow < Gosu::Window
def initialize
super 640, 480, false
self.caption = "Song test"
@songs = [Gosu::Song.new(self, "title_screen.ogg"),
Gosu::Song.new(self, "main.ogg")]
@songs[0].play
end
def button_down(id)
if id == Gosu::KbEscape
close
end
end
end
window = GameWindow.new
window.show
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill