O'Reilly logo

Learn Game Programming with Ruby by Mark Sobkowicz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Make an Empty Window

Each game you’ll write starts by opening a window on your screen. That window is where you’ll bring your games to life, drawing images and making them move. Gosu provides you with a class for drawing that window, called Gosu::Window. This class does more than just draw the window; it also provides methods that give structure to your games. Each time you write a game, you’ll start by creating a subclass of Gosu::Window. For your first game, that subclass will be called WhackARuby.

To create this class, make a new folder called WhackARuby, inside the Games folder you made in Organize Your Workspace. Using your text editor, make a new file and save it in that folder with the name whack_a_ruby.rb.

To use its classes in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required