Advice on setup on Mac

[Apologies if this appears as 2 posts -- my last post never seemed to
make it through]

I just setup NetBeans for Ruby on my Mac (quite like it so far). I'm
familiar to Ruby, getting back to it after a break. I will be using it
with my young kids, teaching them basics of programming to go with
their beginning algebra, physics, etc.

Over time I expect to use command line, simple GUIs, perhaps some
graphics/animation, eventually simple games.

Am seeking advice on the set up for this, what libraries / gems to
use, etc. I am not set on any particular ones, do not need awesome
power, just want something that will work without too much effort on
the Mac.

- Which version of Ruby to use? NetBeans shows a jRuby install +
1.8.6. Pros/cons of 1.9.1 for my usage?

- What tool / gems to use for GUI (Tk? Shoes? Other?

- What tool / gems to use for games (Gosu? Chingu? other?)

Thanks! --- Sophie

- Which version of Ruby to use? NetBeans shows a jRuby install +
1.8.6. Pros/cons of 1.9.1 for my usage?

If you're on OSX, why not try MacRuby?
http://www.macruby.org

- What tool / gems to use for GUI (Tk? Shoes? Other?

Use the cocoa framework :slight_smile: Tightly integrated into macruby, and has a
nice abstract layer called 'hotcocoa' that makes writing cocoa very
rubyish.

- What tool / gems to use for games (Gosu? Chingu? other?)

Not too sure to be honest, I haven't written any games.

An old but good video on macruby can be found here:
http://rubyconf2008.confreaks.com/macruby-ruby-for-your-mac.html

YARV has been dropped from macruby since the making of that video, but
definitely worth the time to watch it.

Hope this helps,
Rob

···

--
Posted via http://www.ruby-forum.com/\.

[Apologies if this appears as 2 posts -- my last post never seemed to
make it through]

I just setup NetBeans for Ruby on my Mac (quite like it so far). I'm
familiar to Ruby, getting back to it after a break. I will be using it
with my young kids, teaching them basics of programming to go with
their beginning algebra, physics, etc.

Over time I expect to use command line, simple GUIs, perhaps some
graphics/animation, eventually simple games.

Am seeking advice on the set up for this, what libraries / gems to
use, etc. I am not set on any particular ones, do not need awesome
power, just want something that will work without too much effort on
the Mac.

- Which version of Ruby to use? NetBeans shows a jRuby install +
1.8.6. Pros/cons of 1.9.1 for my usage?

- What tool / gems to use for GUI (Tk? Shoes? Other?

I am having a lot of success with Fox right now - I find it possible
to build quite a nice interface
with few lines of code, and there's foxGUIb if you want something to
help you build forms.
Its not seamless like Visual Studio dragging and dropping and then
double-clicking a control,
but you can still get a very nice interface working quite quickly once
you have a bit of experience.

- What tool / gems to use for games (Gosu? Chingu? other?)

Gosu is great. Every now and then I take a photo of one of my
daughter's great works of art
and then write a class to specify the behaviour of this new
"character". Then I add the character
to the existing collection and they all move around together in their own way.

My daughter loves to see her art animated and she always has requests when she
sees it: "can I make the doggie move?" etc.

I'll post a few examples (you'll need to add your own custom artwork):

---- basic "character.rb"

class Character
  attr_accessor :x, :y

  def initialize(image, x, y, x_scale = 1, y_scale = 1, col = 0xffffffff)
    @image, @x, @y, @x_scale, @y_scale, @col = image, x, y, x_scale, y_scale, col
  end

  def draw
    @image.draw(@x, @y, 0, @x_scale, @y_scale, @col)
  end

  def update
  end

  def width
    @image.width
  end

  def height
    @image.height
  end
end

---- a "snail.rb"
require 'character'

class Snail < Character
  def initialize(image, x, y)
    super(image, x, y, 0.5, 0.5, 0xffffffff)
  end

  def update
    @x += 1 if(rand(10) < 3)
    @x -= 1 if(rand(10) < 1)
    @x = 0 if @x < 0
    @x = 1280 if @x > 1280
  end
end

---- a "doggie.rb"

require 'character'

class Doggie < Character
  def initialize(image, x, y, x_scale = 1, y_scale = 1, col = 0xffffffff)
    super(image, x, y, x_scale, y_scale, col)
    @s = 0
    @base = 470
    @xr = 0
    @xl = 0
  end

  def update
    @y = @base - 30 * Math::sin(@s)
    @s += 0.1
    @s = 0 if @s >= Math::PI

    if @xr > 0
      @x += 1
      @xr -= 1
    end

    if @xl > 0
      @x -= 1
      @xl -= 1
    end
  end

  def right
    @xr = 50
  end

  def left
    @xl = 50
  end
end

---- some "grass.rb"
require 'character'

class Grass < Character
end

----- the "sun.rb"
require 'character'

class Sun < Character
end

----- main "garden.rb"

#!/usr/bin/ruby

require 'rubygems'
require 'gosu'

require 'snail'
require 'doggie'
require 'sun'
require 'grass'

$W = 1280
$H = 800

class MainWindow < Gosu::Window
  def initialize
    super($W, $H, true)
    self.caption = 'Garden'

    @characters =
      grow_grass(0.6, 10, $H - 226, 0x7fbbbbbb) + #back
      grow_grass(0.7, 9, $H - 194, 0x9fbbbbbb) +
      grow_grass(0.8, 8, $H - 162, 0xbfbbbbbb) +
      grow_grass(0.9, 7, $H - 130, 0xdfbbbbbb) +
      grow_grass(1.0, 6, $H - 98, 0xffbbbbbb) + #front
      [
        Sun.new(Gosu::Image.new(self, 'media/sun-320.png'), $W - 200, 30, 0.5, 0.5),
        @dog = Doggie.new(Gosu::Image.new(self, 'media/doggie-320.png'),
500, $H - 270, 0.5, 0.5),
        Snail.new(Gosu::Image.new(self, 'media/snail-320.png'), 0, $H - 150)
      ]
  end

  def grow_grass(scale, div, y, col)
    blades = Grass.new(Gosu::Image.new(self, 'media/grass-320.png'), 0,
0, scale, scale, col)
    grass =
    div.times do |x|
      b = blades.dup
      b.x = (x * ($W / div)) - 20
      b.y = y
      grass << b
    end
    grass
  end

  def update
    @characters.each {|c| c.update}
  end

  def draw
    draw_quad(0, 0, 0xdd0080ff,
              0, $H, 0x1100ff00,
              $W, $H, 0xffffff00, #top right
              $W, 0, 0x1100ff00) #bottom right
    @characters.each {|c| c.draw}
  end

  def button_down(id)
    close if id == Gosu::Button::KbEscape
    @dog.right if id == Gosu::Button::KbRight
    @dog.left if id == Gosu::Button::KbLeft
  end
end

main = MainWindow.new
main.show

···

On Mon, Nov 16, 2009 at 3:35 AM, Sophie <itsme213@hotmail.com> wrote:

If you're on OSX, why not try MacRuby?http://www.macruby.org

My lack of knowledge :slight_smile: Do you know if NetBeans could be set up to
work with MacRuby?

Cocoa sounds good, but the HotCocoa tutorial page is a "to do" :(.

Does the current MacRuby run most Ruby libs/gems painlessly? I'm a bit
concerned I'd get stuck on something like Gruff (draws graphs) etc.

Hope this helps,

Certainly does, thank you Rob!

Robert Gleeson wrote:

- Which version of Ruby to use? NetBeans shows a jRuby install +
1.8.6. Pros/cons of 1.9.1 for my usage?

If you're on OSX, why not try MacRuby?
http://www.macruby.org

Why bother? The Ruby 1.8.7 interpreter that comes with Leopard and
later is perfectly adequate, unless you specifically want 1.9.

- What tool / gems to use for GUI (Tk? Shoes? Other?

Use the cocoa framework :slight_smile: Tightly integrated into macruby, and has a
nice abstract layer called 'hotcocoa' that makes writing cocoa very
rubyish.

Again, probably not. This is not my area of expertise, but I think most
people use RubyCocoa for cocoa development.

Of course, that only works for Mac (and maybe GnuStep) apps. I'm
working on a cross-platform app now with JRuby and Monkeybars.

- What tool / gems to use for games (Gosu? Chingu? other?)

Not too sure to be honest, I haven't written any games.

Nor have I.

[...]

Hope this helps,
Rob

Best,

···

--
Marnen Laibow-Koser
http://www.marnen.org
marnen@marnen.org
--
Posted via http://www.ruby-forum.com/\.

Leslie Viljoen wrote:

···

On Mon, Nov 16, 2009 at 3:35 AM, Sophie <itsme213@hotmail.com> wrote:

Am seeking advice on the set up for this, what libraries / gems to
use, etc. I am not set on any particular ones, do not need awesome
power, just want something that will work without too much effort on
the Mac.

- Which version of Ruby to use? NetBeans shows a jRuby install +
1.8.6. Pros/cons of 1.9.1 for my usage?

- What tool / gems to use for GUI (Tk? Shoes? Other?

I am having a lot of success with Fox right now - I find it possible
to build quite a nice interface
with few lines of code, and there's foxGUIb if you want something to
help you build forms.

[...]

Fox doesn't work with Aqua, though.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen@marnen.org
--
Posted via http://www.ruby-forum.com/\.

What a fantastic idea!! Thank you!

···

On Nov 16, 5:09 am, Leslie Viljoen <leslievilj...@gmail.com> wrote:

> - What tool / gems to use for games (Gosu? Chingu? other?)

Gosu is great. Every now and then I take a photo of one of my
daughter's great works of art
and then write a class to specify the behaviour of this new
"character". Then I add the character
to the existing collection and they all move around together in their own way.

My daughter loves to see her art animated and she always has requests when she
sees it: "can I make the doggie move?" etc.

I'll post a few examples (you'll need to add your own custom artwork):

Why bother? The Ruby 1.8.7 interpreter that comes with Leopard and
later is perfectly adequate, unless you specifically want 1.9.

Why bother? well, personally i don't develop on 18 anymore - so, yeah, I
want a 19 implementation but macruby has a lot of interesting things
going on, not to mention that it can compile to "highly optimized" OSX
machine code. ( "highly optimized" taken from macruby.org, and only from
macruby 0.5b )
You've also got Obj C's GC to boot.

Again, probably not. This is not my area of expertise, but I think most
people use RubyCocoa for cocoa development.

I advise you to watch the video i posted in my first post :slight_smile: He goes
into all the problems that RubyCocoa has, RubyCocoa is a "bridge"
between C & Obj C but MacRuby has direct access to the Cocoa API on top
of the Obj C runtime - it also has hotcocoa, which is a *damn* cool
abstract API to cocoa for writing sexy GUI apps easily.

Nothing wrong with the official interpreter of course - i use it
everyday, but i think you'd be crazy not to try macruby if you're on a
Mac and moving away from 18(As far as I know, macruby will be the
official 19 interpreter on OSX)

Rob

···

--
Posted via http://www.ruby-forum.com/\.

Cocoa sounds good, but the HotCocoa tutorial page is a "to do" :(.

This might help(but it's a year old):
http://rubyconf2008.confreaks.com/os-x-application-development-with-hotcocoa.html

Does the current MacRuby run most Ruby libs/gems painlessly? I'm a bit
concerned I'd get stuck on something like Gruff (draws graphs) etc.

It should work for gems that are 19 compatiable.
(you can check at http://www.isitruby19.com)

Hope this helps,
Rob

···

--
Posted via http://www.ruby-forum.com/\.

Robert Gleeson wrote:

Why bother? The Ruby 1.8.7 interpreter that comes with Leopard and
later is perfectly adequate, unless you specifically want 1.9.

Why bother? well, personally i don't develop on 18 anymore - so, yeah, I
want a 19 implementation but macruby has a lot of interesting things
going on, not to mention that it can compile to "highly optimized" OSX
machine code. ( "highly optimized" taken from macruby.org, and only from
macruby 0.5b )
You've also got Obj C's GC to boot.

Again, probably not. This is not my area of expertise, but I think most
people use RubyCocoa for cocoa development.

I advise you to watch the video i posted in my first post :slight_smile: He goes
into all the problems that RubyCocoa has, RubyCocoa is a "bridge"
between C & Obj C but MacRuby has direct access to the Cocoa API on top
of the Obj C runtime - it also has hotcocoa, which is a *damn* cool
abstract API to cocoa for writing sexy GUI apps easily.

Interesting. I confess that I don't know much about MacRuby. I may now
have to find out.

Nothing wrong with the official interpreter of course - i use it
everyday, but i think you'd be crazy not to try macruby if you're on a
Mac and moving away from 18

I thought the MacRuby project was stalled or abandoned. Am I wrong?

(As far as I know, macruby will be the
official 19 interpreter on OSX)

What do you mean? 1.9 is already available for Mac, and the official
interpreter isn't MacRuby.

Or are you saying that Apple is planning to include MacRuby 1.9 in
future developer toolkits?

Rob

Best,

···

--
Marnen Laibow-Koser
http://www.marnen.org
marnen@marnen.org
--
Posted via http://www.ruby-forum.com/\.

I thought the MacRuby project was stalled or abandoned. Am I wrong?

I doubt it is :slight_smile: The macruby developer is expected to speak at rubyconf
this year, and 0.5b was released recently.

What do you mean? 1.9 is already available for Mac, and the official
interpreter isn't MacRuby.

Or are you saying that Apple is planning to include MacRuby 1.9 in
future developer toolkits?

Yeah, that was the impression I got from his video(a year old now), but
I would expect that apple will let macruby mature before they start
shipping it with OSX.

···

--
Posted via http://www.ruby-forum.com/\.