Compiling the Gosu Game Development Library on Ubuntu Feisty
Posted by Ryan Baxter Wed, 21 Nov 2007 01:40:00 GMT
I’ve had the itch this week to try out a few of Ruby’s game development libraries. I decided to start with Gosu. Gosu is a 2D game development library for the Ruby and C++ programming languages. It’s available for the Mac OS X, Windows, and Linux platforms and integrates with both the RMagick image processing library and the Chipmunk physics library.
Unfortunately the library is only available as a gem for Mac OS X and Windows. As a Linux user I’ve become accustom to compiling my own libraries, but this often means downloading and compiling dependencies, swearing, and a lot of Googling. I was lucky. Compiling Gosu only caused a few hairs to fall out.
If you’re an Ubuntu Feisty user, you’ll need to add the following line to the LargeImageData.hpp file located in the gosu-source-0.7.7/Gosulmpl/Graphics directory:
#include <boost/none.hpp>This line adds a reference needed on line 31 of the LargeImageData class. With this addition, you can then execute the commands below from the gosu-source-0.7.7/linux directory to compile the Gosu game development library.
$ autoconf
$ ./configure
$ makeThe make file provided with the source does not add the compiled gosu.so file to the Ruby lib directory. I chose to do this manually rather than edit the make file. Just issue the following command from the gosu-source-0.7.7/linux directory to add your newly compiled library.
$ sudo cp gosu.so /usr/lib/ruby/1.8/i486-linux/gosu.soWith a little elbow grease I successfully compiled the Gosu game development library on Ubuntu Feisty. I’ll dig into some tutorials next and post back with my results.
Be sure to check out Gosu’s, Getting Started on Linux, for a list of dependencies and compilation instructions.
/usr/lib/ruby/1.8/rinda/ring.rb:212:in `lookup_ring_any': RingNotFound (RuntimeError)
Posted by Ryan Baxter Sun, 18 Nov 2007 23:44:00 GMT
If you’re experiencing the error message above while using the Rinda distributed computing module in your Ruby script then try defining a Domain name in your Network Settings configuration. This has worked in my experience using Rinda and Ruby on Ubuntu Feisty.

- Meta no comments, permalink, rss, atom
Code Snippet: Ruby Walks with Shoes
Posted by Ryan Baxter Tue, 30 Oct 2007 14:30:00 GMT
_Why of Why’s (Poignant) Guide to Ruby has announced the publication of a 52 page comic style book illustrating the ins and outs of his new windowing toolkit, Shoes. In his words, “Shoes is a very informal graphics and windowing toolkit. It’s for making regular old apps that run on Windows, Mac OS X and Linux. It’s a blend of my favorite things from the Web, some Ruby style, and a sprinkling of cross-platform widgets.”
Using the the latest Shoes revision, I’ve written some code to generate a Mandelbrot fractal. Try it out with the following command (assuming your script is located in the Shoes samples directory):
./shoes samples/mandelbrot.rbYou may want to go make a sandwich while you wait. Here is a sample of the output:

Here is the code:
# RB
require 'complex'
class Mandelbrot
def initialize(bailout=10, iterations=100)
@bailout, @iterations = bailout, iterations
end
# A method for determining if a point is within
# the Mandelbrot set.
def in_set?(x, y)
c = Complex(x, y)
z = 0
@iterations.times do |i|
z = z**2 + c
return false if z > @bailout
end
return true
end
end
class Generator < Shoes
url '/', :index
def index()
render(250, 250, rgb(205, 102, 0))
end
def render(height=250, width=250, color=rgb(255, 0, 0))
nostroke
fill color
mandelbrot = Mandelbrot.new
# Render the fractal.
0.upto(height) do |y|
0.upto(width) do |x|
scaled_x = -2 + (3 * x / width.to_f)
scaled_y = 1 + (-2 * y / height.to_f)
if mandelbrot.in_set?(scaled_x, scaled_y) then
rect :left => x, :top => y, :width => 1, :height => 1
# oval :left => x, :top => y, :radius => 1, :center => true
end
end
end
end
end
Shoes.app :title => 'Mandelbrot', :height => 250, :width => 250- Posted in Code Snippets
- Meta no comments, permalink, rss, atom

