DEV Community

Lori "Lei" Boyd
Lori "Lei" Boyd

Posted on

Making Games in Ruby With Gosu

Have you've ever wanted to make games with ruby? Gosu is a 2D game development library for Ruby and C++. It provides a window and main loop, 2D graphics and text (powered by OpenGL), sound, music, keyboard, mouse, and gamepad input.

Prerequisites & Installation

I'll be showing how to install Gosu on OSX, but they also offer tutorials on setting gosu up with Windows, Linux, Raspbian.

Gosu GitHub wiki

Gosu depends on the SDL 2 library. So make sure you have Homebrew installed and run brew install sdl2. When that's done, simply install the Gosu gem with gem install gosu.

To test whether everything works as expected, you can use this one-liner, which should open a window:

ruby -rgosu -e 'w =, 150); w.caption = "It works!";'

Alt Text

Or you can install and run the gosu-examples gem:

gem install gosu-examples

I recommend you should do the latter.

Alt Text

This tutorial window shows you what Gosu is capable of. Even better, they have a shortcut to the source code for each example! You can view the source code by pressing E And if you like they have a code-along for the tutorial.rb game.


Alt Text

Alt Text

Alt Text

There's so much you can do with this lightweight gem. Here's a link to the Gosu Showsace where you can download community projects or post your own!

Top comments (2)

andrewbrown profile image
Andrew Brown 🇨🇦

I remember gosu, so much fun.