Gosu basics

Sorry this tutorial is quite basic, see here for a better one: http://code.google.com/p/gosu/wiki/RubyTutorial

Gosu has the following useful classes:

Window
Font
Image
Song
Sample

Window

The window is basically where the game is played. Kinda like what game.exe makes in RMXP.

You create it like so:

  1. require 'gosu'
  2.  
  3. class GWindow < Gosu::Window
  4.   def initialize
  5.     super(width, height, fullscreen?)
  6.     self.caption = "caption"
  7.   end
  8.   def update
  9.     # update method
  10.   end
  11. end
  12.  
  13. $window = GWindow.new
  14. $window.show
Expand to see the code.


Image

To draw an image you use the following:

@image = Gosu::Image.new($window, "imagename", hardborders?)
@image.draw(x, y, z)

Font

Text is drawn just like an image.

@text = Gosu::Font.new($window, "text", height)
@text.draw(x, y, z)

Sound

There are two types of sound:

Song: imagine this as a BGM from RMXP.
Sample: imagine as a SE from RMXP.

@short = Gosu::Sample.new($window, "samplename")
@short.play

@long = Gosu::Song.new($window, "songname")
@long.play
what sound formats can Gosu play natively? is it limited to wav and mp3, or can it process ogg and/or module files (xm, mod) as well?
depends in what OS are you running it.
In Windows uses FMOD, in Mac uses OpenAL and in Linux uses SDL_mixer

so check the supported format for your library.
You can check this screenshot taken from Gosu team's website.

http://code.google.com/p/gosu/wiki/SupportedAudioFormats

Content Hidden Show
Image
Are there any examples of anything made within Gosu?
Ah, totally missed this... I guess I didn't really count on anyone being interested in Gosu anymore at all :p

For examples what's being made, you can check out the Showcase Forums on libgosu.org (official site). Don't expect graphical overflow (as I said in my indie community thread, no other community is picky about graphics before mechanics as RM folks are, and therefore, most of the stuff there is selfmade), but do expect interesting concepts on a every-third-thread-the-least basis.
Hello. Gosu can play .ogg. It's significantly less limited than RMXP/VX in what sound formats it can play. HOWEVER! MIDI is not generally supported. IIRC, it's coming in Win/Linux but not for Mac yet unless someone patches in an interface to Core Audio. Also, Windows uses Audiere now instead of FMOD.

I've been working on an interface from RMXP games to the Gosu engine, preserving the RMXP interface. This could also be used for RMVX; the main thing I'm probably never going to code myself is a rewrite of the Tilemap class (all I would need is a good description though, especially how autotiles work), although sprite wave effects are a close second. Right now I'm waiting for better MIDI support. A bug in Gosu that had affected RTP resources has been fixed, and a new Image#insert method looks promising for trying out ImageMagick instead of Texplay to make text rendering and certain other effects much faster.
Sorry if this is a necro, but I was wondering what everyone thinks of Gosu performance?
i.e. Can Ruby be used for serious (2D) game development?
Also, how much of a difference does it make that the rendering is written in C++?
Ruby 1.9.x, especially 1.9.3 is perfectly fine for serious game development.
keeping the rendering part in C++ removes the overhead from the ruby internal operations, and thats a lot since it gets called almost everytime.
Gosu performs especially well on handling images, so if you have a graphics-exhaustive game, you might've found a mate here.
Also, note that there is not only a Ruby-based, but also a C(++)-based version of Gosu that is obviously still better in terms of performance.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=67111