Launcher < Gosu::Window
and Game < Gosu::Window
. First you create and show the Launcher window, and inside you need a method that will call Game.new.show
and close
(in this order) after some event (e.g. key pressed).Gosu::Window
implementations on top of SDL2, and I think that'll make it easier to add support for resolution changing soon. For now the only thing that's guaranteed to work is to have two executables/apps (depending on your OS) and closing the first while launching the second.
$window = GameWindow.new(800,600) #w,h
$window.show
# GameWindow's initialize method:
def initialize(width, height)
super(width, height, false)
...
end
$window.close
$window = GameWindow.new(1024,768)
$window.show
require './lib/engine.rb'
require './lib/home.rb'
loop do
home_window = HomeWindow.new
home_window.show
home_window.close
break if home_window.exit
game_window = GameWindow.new
game_window.show
game_window.close
end
draw
method is stuck on the same frame (may be an issue with update
...) and flopping back and forth between the frame and a black window.
class Window < Gosu::Window
def initialize
super 400, 300, false
self.caption = "Game Launcher!"
@font = Gosu::Font.new(self, "Arial", 16)
@message = "Game Launcher! Press Enter to start game!"
end
def draw
x = self.width / 2 - @font.text_width(@message)/2.0
y = self.height / 2 - 8
@font.draw @message, x, y, 0
end
def button_down id
case id
when Gosu::KbReturn
game_path = "/path/to/Game.app"
if system "open -a #{game_path}"
# successfully opened the game!
close
else
@message = "Failed to open the game!"
end
end
end
end
Window.new.show
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill