gamebox 0.1.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +9 -0
- data/History.txt +5 -0
- data/README.txt +4 -3
- data/Rakefile +12 -4
- data/TODO.txt +1 -5
- data/VERSION +1 -1
- data/docs/getting_started.rdoc +2 -2
- data/gamebox.gemspec +26 -10
- data/lib/gamebox/actor.rb +10 -3
- data/lib/gamebox/actor_factory.rb +2 -2
- data/lib/gamebox/actor_view.rb +14 -11
- data/lib/gamebox/actors/collidable_debugger.rb +35 -0
- data/lib/gamebox/actors/curtain.rb +2 -2
- data/lib/gamebox/actors/logo.rb +0 -6
- data/lib/gamebox/actors/score.rb +2 -5
- data/lib/gamebox/actors/spatial_debugger.rb +47 -0
- data/lib/gamebox/actors/svg_actor.rb +4 -6
- data/lib/gamebox/arbiter.rb +108 -15
- data/lib/gamebox/behavior.rb +29 -1
- data/lib/gamebox/behaviors/animated.rb +14 -23
- data/lib/gamebox/behaviors/audible.rb +1 -12
- data/lib/gamebox/behaviors/collidable.rb +29 -22
- data/lib/gamebox/behaviors/collidable/aabb_collidable.rb +61 -0
- data/lib/gamebox/behaviors/collidable/circle_collidable.rb +17 -0
- data/lib/gamebox/behaviors/collidable/collidable_shape.rb +35 -0
- data/lib/gamebox/behaviors/collidable/polygon_collidable.rb +85 -0
- data/lib/gamebox/behaviors/graphical.rb +13 -10
- data/lib/gamebox/behaviors/layered.rb +6 -20
- data/lib/gamebox/behaviors/physical.rb +116 -93
- data/lib/gamebox/class_finder.rb +6 -2
- data/lib/gamebox/config_manager.rb +24 -4
- data/lib/gamebox/data/config/objects.yml +5 -3
- data/lib/gamebox/ftor.rb +372 -0
- data/lib/gamebox/gamebox_application.rb +2 -8
- data/lib/gamebox/hooked_gosu_window.rb +30 -0
- data/lib/gamebox/input_manager.rb +78 -79
- data/lib/gamebox/lib/code_statistics.rb +1 -1
- data/lib/gamebox/lib/numbers_ext.rb +1 -1
- data/lib/gamebox/lib/rect.rb +612 -0
- data/lib/gamebox/physical_stage.rb +12 -2
- data/lib/gamebox/physics.rb +14 -3
- data/lib/gamebox/resource_manager.rb +28 -65
- data/lib/gamebox/sound_manager.rb +7 -13
- data/lib/gamebox/spatial_hash.rb +60 -14
- data/lib/gamebox/spatial_stagehand.rb +19 -0
- data/lib/gamebox/stage.rb +16 -1
- data/lib/gamebox/stage_manager.rb +1 -1
- data/lib/gamebox/svg_document.rb +1 -0
- data/lib/gamebox/tasks/gamebox_tasks.rb +23 -11
- data/lib/gamebox/templates/template_app/.gitignore +1 -0
- data/lib/gamebox/templates/template_app/Gemfile +1 -1
- data/lib/gamebox/templates/template_app/Rakefile +6 -21
- data/lib/gamebox/templates/template_app/config/environment.rb +14 -0
- data/lib/gamebox/templates/template_app/config/game.yml +2 -1
- data/lib/gamebox/templates/template_app/script/generate +0 -3
- data/lib/gamebox/templates/template_app/src/demo_stage.rb +1 -11
- data/lib/gamebox/templates/template_app/src/game.rb +0 -1
- data/lib/gamebox/templates/template_app/src/my_actor.rb +2 -2
- data/lib/gamebox/version.rb +1 -1
- data/lib/gamebox/views/graphical_actor_view.rb +15 -9
- data/lib/gamebox/wrapped_screen.rb +114 -7
- data/load_paths.rb +20 -0
- data/script/perf_spatial_hash.rb +73 -0
- data/spec/actor_view_spec.rb +1 -1
- data/spec/arbiter_spec.rb +264 -0
- data/spec/behavior_spec.rb +19 -2
- data/spec/collidable_spec.rb +105 -5
- data/spec/helper.rb +1 -1
- data/spec/label_spec.rb +1 -1
- data/spec/resource_manager_spec.rb +1 -1
- data/spec/spatial_hash_spec.rb +1 -1
- metadata +52 -10
- data/lib/gamebox/lib/surface_ext.rb +0 -76
@@ -10,7 +10,7 @@ class StageManager
|
|
10
10
|
@backstage = Backstage.new
|
11
11
|
|
12
12
|
@actor_factory.stage_manager = self
|
13
|
-
stages = @
|
13
|
+
stages = @config_manager.load_config('stage_config')[:stages]
|
14
14
|
|
15
15
|
@stage_names = []
|
16
16
|
@stage_opts = []
|
data/lib/gamebox/svg_document.rb
CHANGED
@@ -1,14 +1,10 @@
|
|
1
1
|
require 'gamebox/lib/platform'
|
2
2
|
|
3
|
-
task :default => :run
|
4
3
|
desc "Run the game"
|
5
4
|
task :run do |t|
|
6
|
-
|
7
|
-
sh "rsdl src/app.rb"
|
8
|
-
else
|
9
|
-
sh "ruby src/app.rb"
|
10
|
-
end
|
5
|
+
sh "ruby src/app.rb"
|
11
6
|
end
|
7
|
+
task :default => :run
|
12
8
|
|
13
9
|
desc "Report code statistics (KLOCs, etc) from the application"
|
14
10
|
task :stats do
|
@@ -19,11 +15,7 @@ end
|
|
19
15
|
|
20
16
|
desc "Run the game with debug server"
|
21
17
|
task :debug do |t|
|
22
|
-
|
23
|
-
sh "rsdl src/app.rb -debug-server"
|
24
|
-
else
|
25
|
-
sh "ruby src/app.rb -debug-server"
|
26
|
-
end
|
18
|
+
sh "ruby src/app.rb -debug-server"
|
27
19
|
end
|
28
20
|
|
29
21
|
desc "Bundle in all required gems"
|
@@ -46,4 +38,24 @@ rescue LoadError
|
|
46
38
|
puts "install with gem install rspec"
|
47
39
|
end
|
48
40
|
|
41
|
+
namespace :dist do
|
42
|
+
task :vendor do
|
43
|
+
sh 'wget http://github.com/downloads/shawn42/gamebox/vendor.zip; unzip vendor.zip; rm vendor.zip'
|
44
|
+
end
|
45
|
+
task :win do
|
46
|
+
# create dist dir
|
47
|
+
FileUtils.mkdir "dist" unless File.exist? "dist"
|
48
|
+
# pull down windows app shell
|
49
|
+
# expand into place
|
50
|
+
sh 'cd dist; wget http://github.com/downloads/shawn42/gamebox/gamebox_app.zip; unzip gamebox_app.zip; mv gamebox_app/* .; rm gamebox_app.zip; rm -rf gamebox_app'
|
51
|
+
|
52
|
+
# copy config/src/lib/data into dist/src
|
53
|
+
%w{vendor config data }.each do |dir|
|
54
|
+
FileUtils.cp_r dir, File.join('dist','src', dir) if File.exist? dir
|
55
|
+
end
|
56
|
+
FileUtils.cp_r 'src', File.join('dist', 'src')
|
57
|
+
|
58
|
+
# create zip of dist?
|
59
|
+
end
|
60
|
+
end
|
49
61
|
|
@@ -3,7 +3,6 @@ $: << libdir
|
|
3
3
|
confdir = File.dirname(__FILE__)+"/config"
|
4
4
|
$: << confdir
|
5
5
|
|
6
|
-
ENV["RUBYGAME_NOINIT"]="1"
|
7
6
|
require 'environment'
|
8
7
|
require 'gamebox/tasks/gamebox_tasks'
|
9
8
|
STATS_DIRECTORIES = [
|
@@ -12,25 +11,11 @@ STATS_DIRECTORIES = [
|
|
12
11
|
%w(Maps maps/),
|
13
12
|
%w(Unit\ tests specs/),
|
14
13
|
%w(Libraries lib/),
|
15
|
-
].collect { |name, dir| [ name, "#{
|
14
|
+
].collect { |name, dir| [ name, "#{dir}" ] }.select { |name, dir| File.directory?(dir) }
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
task :win do
|
22
|
-
# create dist dir
|
23
|
-
FileUtils.mkdir "dist" unless File.exist? "dist"
|
24
|
-
# pull down windows app shell
|
25
|
-
# expand into place
|
26
|
-
sh 'cd dist; wget http://github.com/downloads/shawn42/gamebox/gamebox_app.zip; unzip gamebox_app.zip; mv gamebox_app/* .; rm gamebox_app.zip; rm -rf gamebox_app'
|
27
|
-
|
28
|
-
# copy config/src/lib/data into dist/src
|
29
|
-
%w{vendor config data }.each do |dir|
|
30
|
-
FileUtils.cp_r dir, File.join('dist','src', dir) if File.exist? dir
|
31
|
-
end
|
32
|
-
FileUtils.cp_r 'src', File.join('dist', 'src')
|
33
|
-
|
34
|
-
# create zip of dist?
|
35
|
-
end
|
16
|
+
desc "Report code statistics (KLOCs, etc) from the application"
|
17
|
+
task :stats do
|
18
|
+
require 'code_statistics'
|
19
|
+
CodeStatistics.new(*STATS_DIRECTORIES).to_s
|
36
20
|
end
|
21
|
+
|
@@ -32,6 +32,20 @@ MUSIC_PATH = APP_ROOT + "data/music/"
|
|
32
32
|
GFX_PATH = APP_ROOT + "data/graphics/"
|
33
33
|
FONTS_PATH = APP_ROOT + "data/fonts/"
|
34
34
|
|
35
|
+
require 'rubygems'
|
36
|
+
|
37
|
+
# Set up gems listed in the Gemfile.
|
38
|
+
gemfile = File.expand_path('../../Gemfile', __FILE__)
|
39
|
+
begin
|
40
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
41
|
+
require 'bundler'
|
42
|
+
Bundler.setup
|
43
|
+
rescue Bundler::GemNotFound => e
|
44
|
+
STDERR.puts e.message
|
45
|
+
STDERR.puts "Try running `bundle install`."
|
46
|
+
exit!
|
47
|
+
end if File.exist?(gemfile)
|
48
|
+
|
35
49
|
require 'gamebox'
|
36
50
|
|
37
51
|
GAMEBOX_DATA_PATH = GAMEBOX_PATH + "data/"
|
@@ -1,21 +1,11 @@
|
|
1
1
|
require 'stage'
|
2
|
-
require 'rubygame/ftor'
|
3
2
|
class DemoStage < Stage
|
4
3
|
def setup
|
5
4
|
super
|
6
|
-
@my_actor = create_actor :my_actor
|
7
|
-
@my_actor.x = 10
|
8
|
-
@my_actor.y = 10
|
9
|
-
|
10
|
-
@stars = []
|
11
|
-
20.times { @stars << Ftor.new(rand(viewport.width),rand(viewport.height)) }
|
5
|
+
@my_actor = create_actor :my_actor, :x => 10, :y => 10
|
12
6
|
end
|
13
7
|
|
14
8
|
def draw(target)
|
15
|
-
target.fill [25,25,25,255]
|
16
|
-
for star in @stars
|
17
|
-
target.draw_circle_s([star.x,star.y],1,[255,255,255,255])
|
18
|
-
end
|
19
9
|
super
|
20
10
|
end
|
21
11
|
end
|
@@ -2,8 +2,8 @@ require 'actor'
|
|
2
2
|
require 'actor_view'
|
3
3
|
|
4
4
|
class MyActorView < ActorView
|
5
|
-
def draw(target, x_off, y_off)
|
6
|
-
target.draw_box
|
5
|
+
def draw(target, x_off, y_off, z)
|
6
|
+
target.draw_box @actor.x,@actor.y, 20, 20, [240,45,45,255], 1
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
data/lib/gamebox/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'actor_view'
|
2
2
|
|
3
3
|
class GraphicalActorView < ActorView
|
4
|
-
def draw(target, x_off, y_off)
|
4
|
+
def draw(target, x_off, y_off, z)
|
5
5
|
x = @actor.x
|
6
6
|
y = @actor.y
|
7
7
|
|
@@ -13,25 +13,31 @@ class GraphicalActorView < ActorView
|
|
13
13
|
|
14
14
|
#if @actor.is? :animated or
|
15
15
|
if @actor.is? :physical
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
img_w = img.width
|
17
|
+
img_h = img.height
|
18
|
+
|
19
|
+
offset_x = x-img_w/2 + x_off
|
20
|
+
offset_y = y-img_h/2 + y_off
|
21
|
+
img.draw_rot offset_x, offset_y, z, @actor.rotation
|
20
22
|
else
|
21
23
|
graphical_behavior = @actor.graphical if @actor.is? :graphical
|
22
24
|
if graphical_behavior && graphical_behavior.tiled?
|
23
25
|
x_tiles = graphical_behavior.num_x_tiles
|
24
26
|
y_tiles = graphical_behavior.num_y_tiles
|
25
|
-
img_w, img_h = *img.size
|
27
|
+
# img_w, img_h = *img.size
|
28
|
+
img_w = img.width
|
29
|
+
img_h = img.height
|
26
30
|
x_tiles.times do |col|
|
27
31
|
y_tiles.times do |row|
|
28
|
-
img.blit target.screen, [offset_x+col*img_w,offset_y+row*img_h]
|
32
|
+
# img.blit target.screen, [offset_x+col*img_w,offset_y+row*img_h]
|
33
|
+
img.draw offset_x+col*img_w, offset_y+row*img_h, z
|
29
34
|
end
|
30
35
|
end
|
31
36
|
else
|
32
|
-
img.blit target.screen, [offset_x,offset_y]
|
37
|
+
# img.blit target.screen, [offset_x,offset_y]
|
38
|
+
img.draw offset_x, offset_y, z
|
33
39
|
end
|
34
|
-
|
35
40
|
end
|
41
|
+
target.draw_line(offset_x,offset_y,offset_x+1,offset_y+1,[255,10,10],z)
|
36
42
|
end
|
37
43
|
end
|
@@ -2,15 +2,122 @@ class WrappedScreen
|
|
2
2
|
constructor :config_manager
|
3
3
|
attr_accessor :screen
|
4
4
|
def setup
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
flags << FULLSCREEN if @config_manager[:fullscreen]
|
10
|
-
flags << OPENGL if @config_manager[:opengl]
|
11
|
-
@screen = Screen.open [w,h], 0, flags
|
5
|
+
width, height = *@config_manager[:screen_resolution]
|
6
|
+
fullscreen = @config_manager[:fullscreen]
|
7
|
+
@screen = HookedGosuWindow.new width, height, fullscreen
|
8
|
+
@screen.caption = @config_manager[:title]
|
12
9
|
end
|
10
|
+
|
13
11
|
def method_missing(name,*args)
|
14
12
|
@screen.send name, *args
|
15
13
|
end
|
14
|
+
|
15
|
+
def draw_box(x1,y1,x2,y2,color, z)
|
16
|
+
c = convert_color(color)
|
17
|
+
@screen.draw_line x1, y1, c, x2, y1, c, z
|
18
|
+
@screen.draw_line x2, y1, c, x2, y2, c, z
|
19
|
+
@screen.draw_line x2, y2, c, x1, y2, c, z
|
20
|
+
@screen.draw_line x1, y2, c, x1, y1, c, z
|
21
|
+
end
|
22
|
+
|
23
|
+
def draw_line(x1,y1,x2,y2,color, z)
|
24
|
+
c = convert_color(color)
|
25
|
+
@screen.draw_line x1, y1, c, x2, y2, c, z
|
26
|
+
end
|
27
|
+
|
28
|
+
CIRCLE_STEP = 10
|
29
|
+
# is very expensive
|
30
|
+
# cache it if you can somehow
|
31
|
+
def draw_circle(cx,cy,r,color, z)
|
32
|
+
c_color = convert_color(color)
|
33
|
+
|
34
|
+
x1, y1 = 0, -r
|
35
|
+
circ = 2 * Math::PI * r
|
36
|
+
step = 360 / circ
|
37
|
+
step.step(45, step) { |a|
|
38
|
+
x2, y2 = offset_x(a, r), offset_y(a, r)
|
39
|
+
@screen.draw_line cx + x1, cy + y1, c_color, cx + x2, cy + y2, c_color, z
|
40
|
+
@screen.draw_line cx - x1, cy + y1, c_color, cx - x2, cy + y2, c_color, z
|
41
|
+
@screen.draw_line cx - x1, cy - y1, c_color, cx - x2, cy - y2, c_color, z
|
42
|
+
@screen.draw_line cx + x1, cy - y1, c_color, cx + x2, cy - y2, c_color, z
|
43
|
+
@screen.draw_line cx + y1, cy + x1, c_color, cx + y2, cy + x2, c_color, z
|
44
|
+
@screen.draw_line cx - y1, cy + x1, c_color, cx - y2, cy + x2, c_color, z
|
45
|
+
@screen.draw_line cx - y1, cy - x1, c_color, cx - y2, cy - x2, c_color, z
|
46
|
+
@screen.draw_line cx + y1, cy - x1, c_color, cx + y2, cy - x2, c_color, z
|
47
|
+
x1, y1 = x2, y2
|
48
|
+
}
|
49
|
+
@screen.draw_line cx + x1, cy + y1, c_color, cx - y1, cy - x1, c_color, z
|
50
|
+
@screen.draw_line cx - x1, cy + y1, c_color, cx + y1, cy - x1, c_color, z
|
51
|
+
@screen.draw_line cx - x1, cy - y1, c_color, cx + y1, cy + x1, c_color, z
|
52
|
+
@screen.draw_line cx + x1, cy - y1, c_color, cx - y1, cy + x1, c_color, z
|
53
|
+
end
|
54
|
+
|
55
|
+
# is very expensive
|
56
|
+
# cache it if you can somehow
|
57
|
+
def draw_circle_filled(cx,cy,r,color, z)
|
58
|
+
c_color = convert_color(color)
|
59
|
+
|
60
|
+
x1, y1 = 0, -r
|
61
|
+
circ = 2 * Math::PI * r
|
62
|
+
step = 360 / circ
|
63
|
+
step.step(45, step) { |a|
|
64
|
+
x2, y2 = offset_x(a, r), offset_y(a, r)
|
65
|
+
@screen.draw_quad \
|
66
|
+
cx + x1, cy + y1, c_color, cx + x2, cy + y2, c_color,
|
67
|
+
cx - x2, cy + y2, c_color, cx - x1, cy + y1, c_color, z
|
68
|
+
@screen.draw_quad \
|
69
|
+
cx - x1, cy - y1, c_color, cx - x2, cy - y2, c_color,
|
70
|
+
cx + x2, cy - y2, c_color, cx + x1, cy - y1, c_color, z
|
71
|
+
@screen.draw_quad \
|
72
|
+
cx + y1, cy + x1, c_color, cx + y2, cy + x2, c_color,
|
73
|
+
cx - y2, cy + x2, c_color, cx - y1, cy + x1, c_color, z
|
74
|
+
@screen.draw_quad \
|
75
|
+
cx - y1, cy - x1, c_color, cx - y2, cy - x2, c_color,
|
76
|
+
cx + y2, cy - x2, c_color, cx + y1, cy - x1, c_color, z
|
77
|
+
x1, y1 = x2, y2
|
78
|
+
}
|
79
|
+
@screen.draw_quad \
|
80
|
+
cx + x1, cy + y1, c_color, cx - y1, cy - x1, c_color,
|
81
|
+
cx + y1, cy - x1, c_color, cx - x1, cy + y1, c_color, z
|
82
|
+
@screen.draw_quad \
|
83
|
+
cx - x1, cy - y1, c_color, cx + y1, cy + x1, c_color,
|
84
|
+
cx - y1, cy + x1, c_color, cx + x1, cy - y1, c_color, z
|
85
|
+
end
|
86
|
+
|
87
|
+
def fill_screen(color, z)
|
88
|
+
c = convert_color(color)
|
89
|
+
@screen.draw_quad 0, 0, c, @screen.width, 0, c, 0, @screen.height, c, @screen.width, @screen.height, c, z
|
90
|
+
end
|
91
|
+
|
92
|
+
def fill(x1,y1,x2,y2,color, z)
|
93
|
+
c = convert_color(color)
|
94
|
+
@screen.draw_quad x1, y1, c, x2, y1, c, x1, y2, c, x2, y2, c, z
|
95
|
+
end
|
96
|
+
|
97
|
+
def convert_color(color)
|
98
|
+
@colors ||= {}
|
99
|
+
c = @colors[color]
|
100
|
+
if c.nil?
|
101
|
+
a = color.size == 4 ? color[3] : 255
|
102
|
+
c = Gosu::Color.new a.round, *color[0..2].map{|value|value.round}
|
103
|
+
@colors[color] = c
|
104
|
+
end
|
105
|
+
c
|
106
|
+
end
|
107
|
+
|
108
|
+
def size_text(text, font_file, font_size)
|
109
|
+
@font_cache ||= {}
|
110
|
+
@font_cache[font_file] ||= {}
|
111
|
+
font = @font_cache[font_file][font_size] ||= Font.new(@screen, font_file, font_size)
|
112
|
+
|
113
|
+
return [font.text_width(text),font.height]
|
114
|
+
end
|
115
|
+
|
116
|
+
def render_text(text, font_file, font_size, color)
|
117
|
+
@font_cache ||= {}
|
118
|
+
@font_cache[font_file] ||= {}
|
119
|
+
font = @font_cache[font_file][font_size] ||= Font.new(@screen, font_file, font_size)
|
120
|
+
|
121
|
+
DelayedText.new font, text
|
122
|
+
end
|
16
123
|
end
|
data/load_paths.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
begin
|
2
|
+
require File.expand_path('../.bundle/environment', __FILE__)
|
3
|
+
rescue LoadError
|
4
|
+
begin
|
5
|
+
# bust gem prelude
|
6
|
+
if defined? Gem
|
7
|
+
Gem.cache
|
8
|
+
gem 'bundler'
|
9
|
+
else
|
10
|
+
require 'rubygems'
|
11
|
+
end
|
12
|
+
require 'bundler'
|
13
|
+
Bundler.setup
|
14
|
+
rescue LoadError
|
15
|
+
module Bundler
|
16
|
+
def self.require(*args, &block); end
|
17
|
+
def self.method_missing(*args, &block); end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
$: << File.dirname(__FILE__)+"/../lib/gamebox"
|
2
|
+
|
3
|
+
require 'spatial_hash'
|
4
|
+
require 'new_spatial_hash'
|
5
|
+
require 'benchmark'
|
6
|
+
|
7
|
+
Shape = Struct.new(:x,:y,:width,:height)
|
8
|
+
|
9
|
+
def do_it(hash, num_times, obj_size)
|
10
|
+
num_times.times do |i|
|
11
|
+
hash.add(Shape.new(i,i,obj_size,obj_size))
|
12
|
+
end
|
13
|
+
|
14
|
+
num_times.times do |i|
|
15
|
+
hash.items_at i, i
|
16
|
+
end
|
17
|
+
|
18
|
+
hash.rehash
|
19
|
+
hash.rehash
|
20
|
+
hash.rehash
|
21
|
+
hash.rehash
|
22
|
+
|
23
|
+
num_times.times do |i|
|
24
|
+
hash.items_at i, i
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
OldSpatialHash = SpatialHash
|
29
|
+
|
30
|
+
Benchmark.bm(60) do|b|
|
31
|
+
|
32
|
+
@lots = 1_000
|
33
|
+
@small_grid = 5
|
34
|
+
@medium_grid = 80
|
35
|
+
|
36
|
+
@small_object = 2
|
37
|
+
@medium_object = 20
|
38
|
+
@large_object = 100
|
39
|
+
|
40
|
+
impls = %w{old new}
|
41
|
+
impls.each do |impl|
|
42
|
+
klass = ObjectSpace.const_get "#{impl.capitalize}SpatialHash"
|
43
|
+
b.report("#{impl} w/ lots of small objects in small size grid") do
|
44
|
+
hash = klass.new @small_grid, true
|
45
|
+
do_it(hash,@lots, @small_object)
|
46
|
+
end
|
47
|
+
|
48
|
+
b.report("#{impl} w/ lots of medium objects in small size grid") do
|
49
|
+
hash = klass.new @small_grid, true
|
50
|
+
do_it(hash,@lots, @medium_object)
|
51
|
+
end
|
52
|
+
|
53
|
+
b.report("#{impl} w/ lots of small objects in medium size grid") do
|
54
|
+
hash = klass.new @medium_grid, true
|
55
|
+
do_it(hash,@lots, @small_object)
|
56
|
+
end
|
57
|
+
|
58
|
+
b.report("#{impl} w/ lots of medium objects in medium size grid") do
|
59
|
+
hash = klass.new @medium_grid, true
|
60
|
+
do_it(hash,@lots, @medium_object)
|
61
|
+
end
|
62
|
+
|
63
|
+
b.report("#{impl} w/ lots of large objects in small size grid") do
|
64
|
+
hash = klass.new @small_grid, true
|
65
|
+
do_it(hash,@lots, @large_object)
|
66
|
+
end
|
67
|
+
b.report("#{impl} w/ lots of large objects in small size grid no resize") do
|
68
|
+
hash = klass.new @small_grid, false
|
69
|
+
do_it(hash,@lots, @large_object)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|