J
Jerome David Sallinger
Hello, Is the any connection between a symbol and a class variable. For
example, if I declare the variable @red_car_speed is this aliased or
connected by :red_car_speed. The section of code that is confuring me
is:
-------------------------------------------------------
require 'ruby-processing'
class TwoCarObjects < Processing::App
load_library :control_panel
def setup
control_panel do |c|
c.slider :red_car_speed, -5..15
c.slider :blue_car_speed, -5..15
end
# Initialize car objects
@red_car = Car.new(self, color(255,0,0), 0, 100)
@blue_car = Car.new(self, color(0,0,255), 0, 10)
@red_car_speed = 1
@blue_car_speed = 2
rect_mode CENTER
end
def draw
background 255
# Operate the car object in draw
# by calling object methods using the dots syntax.
@red_car.move(@red_car_speed)
@red_car.display_car
@blue_car.move(@blue_car_speed)
@blue_car.display_car
end
end
example, if I declare the variable @red_car_speed is this aliased or
connected by :red_car_speed. The section of code that is confuring me
is:
-------------------------------------------------------
require 'ruby-processing'
class TwoCarObjects < Processing::App
load_library :control_panel
def setup
control_panel do |c|
c.slider :red_car_speed, -5..15
c.slider :blue_car_speed, -5..15
end
# Initialize car objects
@red_car = Car.new(self, color(255,0,0), 0, 100)
@blue_car = Car.new(self, color(0,0,255), 0, 10)
@red_car_speed = 1
@blue_car_speed = 2
rect_mode CENTER
end
def draw
background 255
# Operate the car object in draw
# by calling object methods using the dots syntax.
@red_car.move(@red_car_speed)
@red_car.display_car
@blue_car.move(@blue_car_speed)
@blue_car.display_car
end
end