summaryrefslogtreecommitdiffstats
path: root/qtruby/rubylib/examples/ruboids/ruboids/Params.rb
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /qtruby/rubylib/examples/ruboids/ruboids/Params.rb
downloadtdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz
tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'qtruby/rubylib/examples/ruboids/ruboids/Params.rb')
-rw-r--r--qtruby/rubylib/examples/ruboids/ruboids/Params.rb87
1 files changed, 87 insertions, 0 deletions
diff --git a/qtruby/rubylib/examples/ruboids/ruboids/Params.rb b/qtruby/rubylib/examples/ruboids/ruboids/Params.rb
new file mode 100644
index 00000000..9ff57851
--- /dev/null
+++ b/qtruby/rubylib/examples/ruboids/ruboids/Params.rb
@@ -0,0 +1,87 @@
+#
+# Copyright (c) 2001 by Jim Menard <jimm@io.com>
+#
+# Released under the same license as Ruby. See
+# http://www.ruby-lang.org/en/LICENSE.txt.
+#
+
+require 'singleton'
+
+$PARAMS = {
+ 'world_sleep_millis' => 75,
+ 'world_width' => 400,
+ 'world_height' => 400,
+ 'world_depth' => 400,
+ 'window_width' => 500,
+ 'window_height' => 500,
+ 'flock_boids' => 10,
+ 'boid_max_speed' => 30,
+ 'boid_bounds_limit_pull' => 5,
+ 'boid_bounds_limit_above_ground_level' => 5,
+ 'boid_wing_length' => 10,
+ 'boid_personal_space_dist' => 12,
+ 'boid_square_of_personal_space_dist' => 144,
+ 'boid_max_perching_turns' => 150,
+ 'boid_perch_wing_flap_percent' => 30,
+ 'cloud_count' => 10,
+ 'cloud_min_speed' => 2,
+ 'cloud_max_speed' => 50,
+ 'cloud_min_bubbles' => 3,
+ 'cloud_max_bubbles' => 10,
+ 'cloud_max_bubble_radius' => 10,
+ 'cloud_min_altitude' => 250,
+ 'camera_x' => 0,
+ 'camera_y' => 0,
+ 'camera_z' => 60,
+ 'camera_rot_x' => 50,
+ 'camera_rot_y' => 10,
+ 'camera_rot_z' => 0,
+ 'camera_zoom' => 1
+}
+
+class Params
+
+ @@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
+)
+
+ 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
+
+end