Sunday, 2 August 2009

Ruby Shoes

I wanted to try ruby Shoes already long ago, but just didn't know what to start with. Until I found a quiteuseful article about making a game on ruby shoes. I tried it and it was unexpectedly easy. Here are some my subjective thoughts about it.

Good things:

It is very easy to study.
One can begin writing using shoes quite quickly and straightforward. No big manuals or hardly understandable api and howtos.
It is cute. :)
Yes, I really liked it. Different objects are created very easy, such as:
Shoes.app { button("Click me!") { alert("Good job.") } }
You also can draw with provided rect, oval or even arrow methods or import an image as a background. Motion ability is also provided:
Shoes.app do #A star that moves after the mouse pointer.
  @shape = star :points => 5
  motion do |left, top|
    @shape.move left, top
  end
end
Unfortunately there were also some disadvantages:
The whole Shoes application should be in Shoes.app block.
Seem to me to be a little bit uncomfortable.
You have to pass everywhere app variable that denotes the Shoes application.
Well, not just everywhere... But if you create your own class, which objects have to be drawn you also have to pass the application variable, or make it global, which is not really good pattern.
class RedRect

  def initialize( app )
    app.fill red
    app.rect :left => 10, :top => 10, :width => 40 
  end
end

Shoes.app do
  RedRect.new( self )
end
Pity, but it is slow.
The resulting snake in the game responds in about 2 seconds. It is a long period of time, especially on higher levels with higher speed.

In conclusion the authors' words about Shoes are right:"Shoes is a tiny graphics toolkit, designed for beginners". It can be used to create quickly a small application, where speed is not essential.

No comments:

Post a Comment