Game Development Reference
In-Depth Information
$ ruby 01-hello/hello_world.rb
You should see a neat small window with your message:
Hello World
See how easy that was? Now let's try to understand what just happened here.
We have extended Gosu::Window with our own GameWindow class, initializing it
as 320x240 window. super passed width , height and fullscreen initialization
parameters from GameWindow to Gosu::Window .
Then we defined our window's caption , and created @message instance variable with
an image generated from text "Hello, World!" using Gosu::Image.from_text .
We have overridden Gosu::Window#draw instance method that gets called every time
Gosu wants to redraw our game window. In that method we call draw on our @message
variable, providing x and y screen coordinates both equal to 10 , and z (depth) value equal
to 0.
Search WWH ::




Custom Search