1. Technology

Game Programming in Ruby with Rubygames

The Main Loop
The main loop is the heartbeat of any game, and is the first thing you need to learn to start making your own games.

Getting Gaming With Rubygame
Loading images from files and displaying them om the screen is the one of the most basic things you can do in game programming. Luckily, Rubygame makes this really simple.

Visual Tutorial: Installing Rubygame on Windows
A visual tutorial with screenshots showing how to install the Rubygame library on Windows, including installing all needed DLL files.

Loading and Displaying Sprites
Now that you know how to load and display a background image in Rubygame, it's time to move onto other graphics, like sprites. A sprite is a smaller graphic displayed on the screen, usually representing the part of the game like the player's ship in Space Invaders or Pac-man in any of the Pac-man games. Backgrounds usually remain static, while sprites can move around and be animated.

Where Do You Get Images for Game Programming?
Game programming can be a fun challenge, but if you're not an artist, too, then the challenge can be finding images to use in the game. Readers share their thoughts about where to find images.

Make Your Sprite Move
Now that we have the player sprite loaded and displayed, and the player itself is a class, it's time to make it move. There are two ways to handle input: handling the events or getting the keyboard state. In this article, only events will be discussed.

Sprite Groups in Rubygame
Now that you have a moving player, the last two things you'll need to add before you have something that can be considered a "game" are enemies and bullets. This article will cover creating an array of enemies and introduce an important concept needed to handle bullets: a sprite group.

Finishing up the Game
Finally, all the pieces are in place for your game. You've learned how to create a game window in Rubygame. You can load and display images on the screen. You can move these images around. You can even arrange these images on the screen into meaningful groups. The last thing you need to make this a "game" is collision detection.

You can opt-out at any time. Please refer to our privacy policy for contact information.

©2014 About.com. All rights reserved.