Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Another Ruby Gosu Game Library Tutorial
Fetching latest commit…
Cannot retrieve the latest commit at this time.
|Failed to load latest commit information.|
This is another ruby tutorial for the awesome Gosu game library. (http://www.libgosu.org) This tutorial builds on the Ruby Tutorial example that is included in the game library. As a project to help teach my teenage son Ruby programming, we dissected the original Gosu Ruby Tutorial and put it back to together in steps to learn the basics of game programming and to make a game of our own. This tutorial borrows heavily from the media assets of the Gosu examples. Running ======= First, you need to install the gosu gem: $ gem install gosu Run the Main.rb file to see the final game: $ ruby Main.rb Background ========== The original Ruby Tutorial featured Asteroids-style navigation where left and right arrow keys rotate the ship, and the up and down keys control thrust and brake. The objective of the tutorial was to fly around the screen collecting stars. This tutorial features "Galaga-style" fixed-angle navigation, where left and right move the ship along the x-axis and up and down move the ship along the y-axis. More importantly we added weapons! The weapons include single-shot (Space Key) and double-shot (Option/Alt Key) lasers, a "super shot" cannon (Control Key) that fires slowly but destroys anything in its path, and finally a nuke (N Key) that clears all obstacles from the screen when detonated. The nuke is only available if the ship's power level is full. While in the original tutorial flying over a star would "collect" the star, in this tutorial hitting a star with your ship destroys the ship with an appropriately gratuitous explosion. To protect your ship you have a shield (Shift Key) that can be activated provided the ship's energy tank is not empty. Pressing 'P' will pause the game and display the various controls. There are cheat codes available on the pause screen, but you will have to look through the source code to discover what those are. This tutorial is broken into 6 steps: 01_basic_window.rb -- demonstrates Gosu::Window and its update/draw loop 02_graphics.rb -- demonstrates loading images and drawing to the window 03_basic_control.rb -- demonstrates input with a Ship that can fly around the screen 04_sounds_and_weaponry.rb -- adds weapons and sounds to 03_basic_control 05_collisions.rb -- add Stars as obstacles with simple collision detection Main.rb -- complete game with user interface, life counting, pause, etc. Classes are organized into separate files in lib directory