We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpProcessing Implementations › Long Email :Ruby-p55 & rubyonpro555 newbie queries
Page Index Toggle Pages: 1
Long Email :Ruby-p55 & rubyonpro555 newbie queries (Read 1722 times)
Long Email :Ruby-p55 & rubyonpro555 newbie queries
Jun 30th, 2009, 6:13am
 
Hi All,

First time here. First of all Thanks to the creators of Processing , ruby-processing and rubyonprocessing. Great work. I have been trying the plain vanillla PDE and also the various ruby implementations. However I have ran into a problem everytime I try to use the ">=" or "<=" I run into trouble. The jruby stack elided error is not helping much. I would rather do all my coding in the original PDE but my computer seems to take forever to load it. (ArchLinux Kernel 2.6.29 jdk6) Hence I am using the two ruby versions. However both 'rp5' and 'rop' are crashing at the same point. I have attached the file. I hope it is not some stupid mistake on my part. If so I'm sorry. But I have honestly checked all that I could before posting this.

Thanks for all your help in advance.

Smiley


--- sorry I had to use this instead of attaching the file.
#def initialize
#      @win_width = 400
#      @win_height = 300
#end

public class Ball
     @@ball_counter = 0

     def initialize(temprad )
           @temprad = temprad
           @xpos = random(width)
           @ypos = random(height)
           @xspeed = random(-5,5)
           @yspeed = random(-5,5)
           @ballcolor = color(100,50)

           @@ball_counter += 1
     end

     #this creates setter and getter methods for
     #@temprad
     attr_accessor :temprad , :xpos , :ypos, :xspeed, :yspeed, :ballcolor

     def move
           @xpos += @xspeed
           @ypos += @yspeed

           if @x >  width
                 @xspeed *= -1
           end
           
           #if (@x > width ||  @x < 0)
           #      @xspeed *= -1
           #end
           #
           #
           #if (@y > height ||  @y < 0)
           #      @yspeed *= -1
           #end
           
           #if (@x > @win_height || @x < 0)
           #      @xspeed *= -1
           #end


           #if (@y > @win_height || @y < 0)
           #      @yspeed *= -1
           #end

           
     end

     def display
           stroke 0
           fill @ballcolor
           ellipse @xpos, @ypos, @temprad * 2, @temprad * 2
     end


     #Class method (also called static method
     def Ball.number_of_Balls
           @@ball_counter
     end
end

def setup
     size 400, 300 #width, height
end

def draw
     background 205
     aBall = Ball.new 25
     bBall = Ball.new 50
     aBall.display
     bBall.display

     aBall.move
     bBall.move


end


Re: Long Email :Ruby-p55 & rubyonpro555 newbie queries
Reply #1 - Jul 2nd, 2009, 7:29pm
 
Works just fine in Ruby-Processing, after the removal of a confused bit of Java and a typo:

Delete the "public" from the front of your Ball class definition, and change "@x > width" to "@xpos > width", and you're good to go.
Re: Long Email :Ruby-p55 & rubyonpro555 newbie queries
Reply #2 - Jul 2nd, 2009, 8:50pm
 
Thank you jashkenas.
Truly appreciate the help. I spend a lot of time on it but thanks for stepping in and helping me out. Now I am back to having more fun with ruby + processing Wink.  
Also thanks a lot for creating and releasing ruby-processing. I mean Processing is awesome ruby-processing is fun...

Thanks again.
Page Index Toggle Pages: 1