Gosu Makes Writing Games Easy
Gosu is a fantastic little library for making basic 2D games using Ruby. There are extensions to add 3D graphics, common game logic, and a physics engine. You install Gosu the normal ruby way:
The basics of Gosu are simple:
- Write a class that inherits from Gosu::Window
- In the initializer call super with the width, height, and whether you want your app to be fullscreen
- define a draw method that uses the Gosu library functions to render graphics on the screen
- define an update method that makes changes to your game
- Write Class.new.show
- That’s it
Gosu automatically calls the draw method followed by the update method followed by draw again. It does this as often as it can which means the framerate varies depending on how complicated your draw and update methods are.
With this basic framework you can make simple animations and 2D games. Here is a simple animation of a square going diagonally across the screen.