Ruby Game Development with the Gosu Game Engine
Hello everyone,
I was bored one day so I decided to start a game development series using the
programming language Ruby
Why Ruby?
Ruby has become a very popular programming language over the
past few years. It's a wonderful language for hacking, design, and
programming, not to mention an awesome tool for scripting.
In this series we will be creating a tile-based game using the Shining Force II tileset,
let's just call our new game "Shining Force: The Legend of Ruby"
For starters we need to get the Ruby programming language installed on your machine.
Linux Installation
Now if your a Linux user like myself things are a lot easier to work with. Just login as root and execute the following command.
$ sudo apt-get install ruby
Viola! Ruby will be installed in a matter of seconds
MacOSX Installation
MacOSX users have it easy, ruby should be installed with your operating system.
You can just grab the latest game engine using the following command.
$ sudo gem install gosu
"gem" gives you access to a giant repository of ruby programs.
If the gem command wasn't found you'll have to install it using the source which can be downloaded here:
http://rubyforge.org/frs/download.ph...gems-1.3.1.tgz
Download an extract it, then from terminal run the following commands
./configure make sudo make install
Windows Installation
Ruby has an interactive installer for windows which can be downloaded at http://www.ruby-lang.org/en/downloads/
Download and install the latest version of the One-Click-Installer at ruby-lang.org.
Enable Rubygems!!
Meet Interactive Ruby (irb), your new best friend
Now that you have Ruby installed we should be able to execute the ruby irb in terminal or "command prompt" for windows users.
For ease sake if your on windows just think of "command prompt" as terminal.
Open terminal up and execute the following command (Note: don't enter ">", it's just irb)
> irb
The irb should open up and display
irb(main):001:0>
You can issue various instructions to the Ruby interpreter, try entering "1 + 1", "4 /2" .. etc
you can quit the interpreter by typing "quit"
Gosu Game Engine Installation
If your on windows, chances you are you'll need to create a shortcut on your desktop to command prompt.
Right-click, create shortcut, for the target enter cmd and hit enter. This should create a shortcut to command-prompt.
Once you have your shortcut right-click and his "Run as administrator"
(Node: We need administrator rights to install the game engine)
We're finally at the stage for installing the Gosu. From prompt just execute the following command.
gem install gosu
Once Gosu is installed the real magic of Ruby happens! We're going to create our first script with Ruby.
Create a folder for our project, preferably in C:/GameDev/Zelda
Create a file called main.rb and write the following script to it:
begin # In case you use Gosu via RubyGems. require 'rubygems' rescue LoadError # In case you don't. end require 'gosu' class MyWindow < Gosu::Window def initialize super(640, 480, false, 20) self.caption = 'Hello World!' end end w = MyWindow.new w.show
Once you do this launch the script by either double-clicking on it (Windows) or from terminal by
issuing the command
ruby main.rb
If it was successful you should see a black window pop-up with a caption that says "Hello World!"
Stay tuned for the next tutorial...