Class: Params

Inherits:
Object show all
Defined in:
ext/ruby/qtruby/examples/ruboids/ruboids/Params.rb

Constant Summary collapse

@@reals =
%w(
world_width
world_height
world_depth
boid_max_speed
boid_bounds_limit_pull
boid_bounds_limit_above_ground_level
boid_wing_length
boid_personal_space_dist
boid_square_of_personal_space_dist
cloud_min_speed
cloud_max_speed
cloud_max_bubble_radius
cloud_min_altitude
camera_x
camera_y
camera_z
camera_rot_x
camera_rot_y
camera_rot_z
camera_zoom
)

Class Method Summary collapse

Class Method Details

.readParamsFromFile(paramFileName) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/Params.rb', line 67

def Params.readParamsFromFile(paramFileName)
	File.open(paramFileName).each { | line |
 line.chomp!
 next if line.empty? || line =~ /^#/

 key, value = line.split(/\s*=\s*/)
 next unless value
 key.downcase!()
 key.gsub!(/\./, '_')

 isReal = @@reals.include?(key)
 value = value.to_f if isReal
 value = value.to_i if !isReal
 $PARAMS[key] = value
	}
	$PARAMS['boid_square_of_personal_space_dist'] =
 $PARAMS['boid_personal_space_dist'] *
 $PARAMS['boid_personal_space_dist']
end