The "Scene" style workings of RPG maker are even easier to implement into Gosu.
First you need a scene:
We don't need to update Graphics like in RPG Maker; nor do we need to run a loop (see below).
We need our game window:
The method initialize is called when the game is first opened. As such this can be used to call our initial scene (here, Scene_Start).
The method update is ran once per frame, automatically. Therefore, we can call our scene update methods here for convenience.
From before you'll note that super(x, y, fullscreen?) here makes the window 640x480, with no fullscreen mode.
Now all that remains is to call the script:
Demo
You'll noticed I added a draw_text method; this was just for ease and probably wasn't needed. Nonetheless, play around with the "demo" some and yeah.
This probably didn't need a tutorial; nonetheless if you have any problems with this post here.
First you need a scene:
Code:
class Scene_Start
def update
end
end
We don't need to update Graphics like in RPG Maker; nor do we need to run a loop (see below).
We need our game window:
Code:
class Game < Window
def initialize
super(640, 480, false)
self.caption = "Scene Changing Demo"
$scene = Scene_Start.new
end
def update
$scene.update
end
end
The method initialize is called when the game is first opened. As such this can be used to call our initial scene (here, Scene_Start).
The method update is ran once per frame, automatically. Therefore, we can call our scene update methods here for convenience.
From before you'll note that super(x, y, fullscreen?) here makes the window 640x480, with no fullscreen mode.
Now all that remains is to call the script:
Code:
$game = Game.new
$game.show
Demo
Code:
require 'rubygems'
require 'gosu'
include Gosu
class Scene_End
def update
$game.draw_text('Scene_End (Press Down to close)', 0, 0, 0)
if $game.button_down?(Button::KbDown)
exit
end
end
end
class Scene_Start
def update
$game.draw_text('Scene_Start (Press Up to continue)', 0, 0, 0)
if $game.button_down?(Button::KbUp)
$scene = Scene_End.new
end
end
end
class Game < Window
def initialize
super(640, 480, false)
self.caption = "Scene Changing Demo"
$scene = Scene_Start.new
@font = Font.new(self, "Times New Roman", 24)
end
def update
$scene.update
end
def draw_text(text, x, y, z)
@font.draw(text, x, y, z, 1, 1)
end
end
$game = Game.new
$game.show
You'll noticed I added a draw_text method; this was just for ease and probably wasn't needed. Nonetheless, play around with the "demo" some and yeah.
This probably didn't need a tutorial; nonetheless if you have any problems with this post here.