gamebox 0.3.4 → 0.4.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. data/README.rdoc +38 -0
  2. data/Rakefile +1 -10
  3. data/TODO.txt +6 -6
  4. data/app_generators/gamebox_generator.rb +95 -0
  5. data/{lib/gamebox/templates/template_app → app_generators/templates}/.gitignore +0 -0
  6. data/app_generators/templates/Gemfile +7 -0
  7. data/app_generators/templates/NEXT_STEPS.txt +1 -0
  8. data/{lib/gamebox/templates/template_app/README → app_generators/templates/README.rdoc} +0 -0
  9. data/{lib/gamebox/templates/template_app → app_generators/templates}/Rakefile +0 -0
  10. data/{lib/gamebox/templates/template_app → app_generators/templates}/config/boot.rb +0 -0
  11. data/app_generators/templates/config/environment.rb +30 -0
  12. data/{lib/gamebox/templates/template_app → app_generators/templates}/config/game.yml +0 -0
  13. data/{lib/gamebox/templates/template_app → app_generators/templates}/data/fonts/FONTS_GO_HERE +0 -0
  14. data/{lib/gamebox/templates/template_app → app_generators/templates}/data/graphics/GRAPHICS_GO_HERE +0 -0
  15. data/{lib/gamebox/templates/template_app → app_generators/templates}/data/music/MUSIC_GOES_HERE +0 -0
  16. data/{lib/gamebox/templates/template_app → app_generators/templates}/data/sounds/SOUND_FX_GO_HERE +0 -0
  17. data/{lib/gamebox/templates → app_generators/templates/script}/actor.erb +0 -0
  18. data/{lib/gamebox/templates → app_generators/templates/script}/actor_spec.erb +0 -0
  19. data/{lib/gamebox/templates → app_generators/templates/script}/actor_view.erb +0 -0
  20. data/{lib/gamebox/templates → app_generators/templates/script}/actor_view_spec.erb +0 -0
  21. data/app_generators/templates/script/generate +12 -0
  22. data/{lib/gamebox/templates/template_app → app_generators/templates}/spec/helper.rb +0 -0
  23. data/app_generators/templates/src/actors/player.rb +8 -0
  24. data/{lib/gamebox/templates/template_app → app_generators/templates}/src/app.rb +0 -0
  25. data/app_generators/templates/src/demo_stage.rb +7 -0
  26. data/bin/gamebox +8 -70
  27. data/component_generators/actor_generator.rb +17 -0
  28. data/docs/CODE_REVIEW +1 -1
  29. data/docs/REFACTOR_NOTES.txt +25 -0
  30. data/docs/getting_started.rdoc +1 -1
  31. data/gamebox.gemspec +7 -4
  32. data/lib/gamebox.rb +6 -3
  33. data/lib/gamebox/actors/collidable_debugger.rb +13 -15
  34. data/lib/gamebox/actors/curtain.rb +44 -43
  35. data/lib/gamebox/actors/emitter.rb +3 -42
  36. data/lib/gamebox/actors/fps.rb +13 -6
  37. data/lib/gamebox/actors/label.rb +42 -34
  38. data/lib/gamebox/actors/logo.rb +2 -4
  39. data/lib/gamebox/actors/score.rb +37 -27
  40. data/lib/gamebox/actors/svg_actor.rb +45 -32
  41. data/lib/gamebox/behaviors/animated.rb +39 -59
  42. data/lib/gamebox/behaviors/audible.rb +14 -14
  43. data/lib/gamebox/behaviors/collidable.rb +65 -36
  44. data/lib/gamebox/behaviors/collidable/aabb_collidable.rb +2 -3
  45. data/lib/gamebox/behaviors/collidable/collidable_shape.rb +6 -4
  46. data/lib/gamebox/behaviors/collidable/polygon_collidable.rb +1 -1
  47. data/lib/gamebox/behaviors/emitting.rb +48 -0
  48. data/lib/gamebox/behaviors/graphical.rb +22 -56
  49. data/lib/gamebox/behaviors/layered.rb +8 -21
  50. data/lib/gamebox/behaviors/physical.rb +202 -213
  51. data/lib/gamebox/behaviors/positioned.rb +16 -0
  52. data/lib/gamebox/behaviors/projectile.rb +15 -0
  53. data/lib/gamebox/behaviors/visible.rb +16 -0
  54. data/lib/gamebox/core/aabb_helpers.rb +61 -0
  55. data/lib/gamebox/core/aabb_node.rb +118 -0
  56. data/lib/gamebox/core/aabb_tree.rb +137 -0
  57. data/lib/gamebox/core/actor.rb +102 -0
  58. data/lib/gamebox/core/actor_factory.rb +56 -0
  59. data/lib/gamebox/core/actor_view.rb +63 -0
  60. data/lib/gamebox/core/actor_view_factory.rb +40 -0
  61. data/lib/gamebox/{arbiter.rb → core/arbiter.rb} +31 -34
  62. data/lib/gamebox/{backstage.rb → core/backstage.rb} +0 -0
  63. data/lib/gamebox/core/behavior.rb +64 -0
  64. data/lib/gamebox/core/behavior_factory.rb +56 -0
  65. data/lib/gamebox/{class_finder.rb → core/class_finder.rb} +0 -0
  66. data/lib/gamebox/{config_manager.rb → core/config_manager.rb} +1 -1
  67. data/lib/gamebox/core/configuration.rb +39 -0
  68. data/lib/gamebox/core/core.rb +30 -0
  69. data/lib/gamebox/core/deprecated.rb +15 -0
  70. data/lib/gamebox/{director.rb → core/director.rb} +6 -11
  71. data/lib/gamebox/core/font_style.rb +26 -0
  72. data/lib/gamebox/core/font_style_factory.rb +11 -0
  73. data/lib/gamebox/core/game.rb +19 -0
  74. data/lib/gamebox/{hooked_gosu_window.rb → core/hooked_gosu_window.rb} +12 -6
  75. data/lib/gamebox/{input_manager.rb → core/input_manager.rb} +106 -99
  76. data/lib/gamebox/core/physics.rb +22 -0
  77. data/lib/gamebox/{physical_stage.rb → core/physics_manager.rb} +36 -30
  78. data/lib/gamebox/{resource_manager.rb → core/resource_manager.rb} +19 -18
  79. data/lib/gamebox/{sound_manager.rb → core/sound_manager.rb} +9 -7
  80. data/lib/gamebox/{stage.rb → core/stage.rb} +42 -80
  81. data/lib/gamebox/{stage_manager.rb → core/stage_manager.rb} +46 -53
  82. data/lib/gamebox/{stagehand.rb → core/stagehand.rb} +0 -0
  83. data/lib/gamebox/{svg_document.rb → core/svg_document.rb} +0 -0
  84. data/lib/gamebox/core/timer_manager.rb +50 -0
  85. data/lib/gamebox/{viewport.rb → core/viewport.rb} +2 -3
  86. data/lib/gamebox/{wrapped_screen.rb → core/wrapped_screen.rb} +12 -19
  87. data/lib/gamebox/gamebox_application.rb +7 -15
  88. data/lib/gamebox/lib/evented_attributes.rb +51 -0
  89. data/lib/gamebox/{ftor.rb → lib/ftor.rb} +0 -0
  90. data/lib/gamebox/lib/min_max_helpers.rb +10 -0
  91. data/lib/gamebox/lib/rect.rb +112 -54
  92. data/lib/gamebox/lib/yoda.rb +46 -0
  93. data/lib/gamebox/spec/helper.rb +317 -12
  94. data/lib/gamebox/stagehands/spatial_tree_stagehand.rb +61 -0
  95. data/lib/gamebox/version.rb +8 -3
  96. data/lib/gamebox/views/graphical_actor_view.rb +22 -29
  97. data/script/perf_aabb.rb +56 -0
  98. data/script/perf_array_access.rb +16 -0
  99. data/script/perf_collisions.rb +37 -18
  100. data/script/perf_struct_vs_array.rb +7 -7
  101. data/spec/acceptance/animation_spec.rb +65 -0
  102. data/spec/acceptance/basic_actor_lifecycle_spec.rb +92 -0
  103. data/spec/acceptance/built_in_collision_handling_spec.rb +55 -0
  104. data/spec/acceptance/chipmunk_collision_handling_spec.rb +83 -0
  105. data/spec/acceptance/fps_actor_spec.rb +40 -0
  106. data/spec/acceptance/pausing_spec.rb +61 -0
  107. data/spec/acceptance/timer_usage_spec.rb +53 -0
  108. data/spec/actors/emitter_spec.rb +5 -0
  109. data/spec/{label_spec.rb → actors/label_spec.rb} +1 -1
  110. data/spec/behaviors/animated_spec.rb +85 -0
  111. data/spec/behaviors/collidable_spec.rb +134 -0
  112. data/spec/{physical_spec.rb → behaviors/physical_spec.rb} +2 -1
  113. data/spec/behaviors/positioned_spec.rb +6 -0
  114. data/spec/behaviors/projectile_spec.rb +6 -0
  115. data/spec/core/aabb_tree_spec.rb +109 -0
  116. data/spec/core/actor_factory_spec.rb +44 -0
  117. data/spec/core/actor_spec.rb +78 -0
  118. data/spec/core/actor_view_spec.rb +53 -0
  119. data/spec/{arbiter_spec.rb → core/arbiter_spec.rb} +29 -30
  120. data/spec/core/backstage_spec.rb +37 -0
  121. data/spec/core/behavior_factory_spec.rb +50 -0
  122. data/spec/core/behavior_spec.rb +8 -0
  123. data/spec/core/configuration_spec.rb +8 -0
  124. data/spec/core/core_spec.rb +13 -0
  125. data/spec/core/font_style_factory_spec.rb +17 -0
  126. data/spec/core/font_style_spec.rb +41 -0
  127. data/spec/core/hooked_gosu_window_spec.rb +75 -0
  128. data/spec/core/input_manager_spec.rb +285 -0
  129. data/spec/core/physics_manager_spec.rb +11 -0
  130. data/spec/core/resource_manager_spec.rb +12 -0
  131. data/spec/core/stage_manager_spec.rb +140 -0
  132. data/spec/core/stage_spec.rb +73 -0
  133. data/spec/core/timer_manager_spec.rb +89 -0
  134. data/spec/{viewport_spec.rb → core/viewport_spec.rb} +6 -3
  135. data/spec/core/wrapped_screen_spec.rb +26 -0
  136. data/spec/fixtures/game.yml +7 -0
  137. data/spec/fixtures/snelpling/idle/1.png +0 -0
  138. data/spec/fixtures/snelpling/jump/1.png +0 -0
  139. data/spec/fixtures/snelpling/jump/2.png +0 -0
  140. data/spec/fixtures/snelpling/jump/3.png +0 -0
  141. data/spec/helper.rb +8 -0
  142. data/spec/{class_finder_spec.rb → lib/class_finder_spec.rb} +2 -1
  143. data/spec/stagehands/spatial_tree_stagehand_spec.rb +19 -0
  144. data/spec/views/graphical_actor_view_spec.rb +116 -0
  145. metadata +343 -144
  146. data/README.txt +0 -34
  147. data/lib/gamebox/actor.rb +0 -179
  148. data/lib/gamebox/actor_factory.rb +0 -57
  149. data/lib/gamebox/actor_view.rb +0 -44
  150. data/lib/gamebox/actors/spatial_debugger.rb +0 -62
  151. data/lib/gamebox/behavior.rb +0 -70
  152. data/lib/gamebox/behaviors/timed.rb +0 -33
  153. data/lib/gamebox/behaviors/updatable.rb +0 -12
  154. data/lib/gamebox/console_app.rb +0 -41
  155. data/lib/gamebox/gamebox_generator.rb +0 -32
  156. data/lib/gamebox/generators/actor_generator.rb +0 -43
  157. data/lib/gamebox/generators/view_generator.rb +0 -42
  158. data/lib/gamebox/physical_director.rb +0 -17
  159. data/lib/gamebox/physics.rb +0 -32
  160. data/lib/gamebox/spatial_bucket.rb +0 -9
  161. data/lib/gamebox/spatial_hash.rb +0 -194
  162. data/lib/gamebox/spatial_stagehand.rb +0 -80
  163. data/lib/gamebox/templates/template_app/Gemfile +0 -6
  164. data/lib/gamebox/templates/template_app/config/environment.rb +0 -23
  165. data/lib/gamebox/templates/template_app/config/stage_config.yml +0 -2
  166. data/lib/gamebox/templates/template_app/script/generate +0 -7
  167. data/lib/gamebox/templates/template_app/src/demo_stage.rb +0 -11
  168. data/lib/gamebox/templates/template_app/src/game.rb +0 -19
  169. data/lib/gamebox/templates/template_app/src/my_actor.rb +0 -14
  170. data/script/perf_spatial_hash.rb +0 -64
  171. data/spec/actor_factory_spec.rb +0 -61
  172. data/spec/actor_spec.rb +0 -71
  173. data/spec/actor_view_spec.rb +0 -61
  174. data/spec/animated_spec.rb +0 -83
  175. data/spec/backstage_spec.rb +0 -45
  176. data/spec/behavior_spec.rb +0 -28
  177. data/spec/collidable_spec.rb +0 -135
  178. data/spec/emitter_spec.rb +0 -20
  179. data/spec/input_manager_spec.rb +0 -134
  180. data/spec/resource_manager_spec.rb +0 -13
  181. data/spec/spatial_hash_spec.rb +0 -119
  182. data/spec/spatial_stagehand_spec.rb +0 -93
  183. data/spec/stage_manager_spec.rb +0 -25
  184. data/spec/stage_spec.rb +0 -65
@@ -1,4 +1,5 @@
1
- require File.join(File.dirname(__FILE__),'helper')
1
+ __END__
2
+ require 'helper'
2
3
 
3
4
  # Only run these if the user has chipmunk installed
4
5
  if defined? CP
@@ -0,0 +1,6 @@
1
+ require 'helper'
2
+
3
+ describe :positioned do
4
+ it 'defines x,y on actor'
5
+ it 'rolls up x and y changes to position_changed on update'
6
+ end
@@ -0,0 +1,6 @@
1
+ require 'helper'
2
+
3
+ describe :positioned do
4
+ it 'defines vel_x, vel_y on actor'
5
+ it 'updates x and y based on vel_(x,y) scaled to seconds'
6
+ end
@@ -0,0 +1,109 @@
1
+ require 'helper'
2
+
3
+ describe AABBTree do
4
+
5
+ let(:one) { bb('one', 0,0,1,1) }
6
+ let(:two) { bb('two', 5,9,1,1) }
7
+ let(:three) { bb('three', 7,10,5,1) }
8
+ let(:four) { bb('four', -10,-50,20,5) }
9
+
10
+ describe '#insert' do
11
+ it 'adds a single item' do
12
+ subject.insert one
13
+ subject.should be_valid
14
+ subject.should include(one)
15
+
16
+ root = root(subject)
17
+ root.object.should == one
18
+ root.bb.should == Rect.new(0,0,2,2)
19
+ root.a.should be_nil
20
+ root.b.should be_nil
21
+ end
22
+ end
23
+
24
+ describe "the whole tree" do
25
+ it 'works' do
26
+ # NOTE: its 3am, I'm bastardizing this test case
27
+ subject.insert one
28
+ subject.insert two
29
+ subject.insert three
30
+ subject.size.should == 3
31
+ subject.valid?.should be_true
32
+ # puts subject.to_s
33
+
34
+ subject.remove one
35
+ subject.size.should == 2
36
+ # puts subject.to_s
37
+
38
+ subject.query one.bb do |node|
39
+ fail "should not have found one since we removed it"
40
+ end
41
+
42
+ found_items = []
43
+ subject.query two.bb do |item|
44
+ found_items << item
45
+ end
46
+ found_items.should == [two, three]
47
+
48
+ found_items = []
49
+ subject.update two
50
+ subject.update three
51
+ subject.insert four
52
+ subject.query [1,1,10,10] do |item|
53
+ found_items << item
54
+ end
55
+ found_items.should == [two, three]
56
+ subject.valid?.should be_true
57
+
58
+ subject.valid?.should be_true
59
+ two.bb = Rect.new -10, -10, 1, 1
60
+ subject.update two
61
+ subject.valid?.should be_true
62
+ found_items = []
63
+ subject.query [1,1,10, 10] do |item|
64
+ found_items << item
65
+ end
66
+ found_items.should == [three]
67
+
68
+ them = []
69
+ subject.each do |item|
70
+ them << item
71
+ end
72
+ them.map(&:object_id).size.should == 3
73
+ subject.valid?.should be_true
74
+
75
+ them = []
76
+ two.bb = Rect.new 5, 8, 6, 10
77
+ subject.update two
78
+ found_items = []
79
+ subject.collisions two do |item|
80
+ found_items << item
81
+ end
82
+ found_items.should =~ [three]
83
+ subject.valid?.should be_true
84
+ end
85
+ end
86
+
87
+ private
88
+ def bb(*args)
89
+ BBItem.new *args
90
+ end
91
+
92
+ def root(tree)
93
+ tree.instance_variable_get('@root')
94
+ end
95
+
96
+ class BBItem
97
+ extend Publisher
98
+ can_fire :moved, :remove_me
99
+ attr_accessor :name, :bb
100
+ def initialize(name, x,y,w,h)
101
+ @name = name
102
+ @bb = Rect.new x, y, w, h
103
+ end
104
+
105
+ def to_s
106
+ "#{name} : #{bb}"
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,44 @@
1
+ require 'helper'
2
+ describe ActorFactory do
3
+ inject_mocks :input_manager, :wrapped_screen, :this_object_context,
4
+ :resource_manager, :behavior_factory, :actor_view_factory
5
+
6
+ before do
7
+ @opts = {:foo => :bar}
8
+ @merged_opts = @opts.merge(actor_type: :some_actor)
9
+ end
10
+
11
+ describe "#build" do
12
+ # Actor.definitions.clear
13
+ # ActorView.definitions.clear
14
+ Actor.define :some_actor
15
+ ActorView.define :some_actor_view
16
+
17
+ let(:actor) { create_actor }
18
+ let(:actor_view) { create_actor_view :actor_view, {}, false }
19
+
20
+ before do
21
+ @actor = actor
22
+ @subcontext = stub('subcontext')
23
+ @subcontext.stubs(:[]).with(:actor).returns(actor)
24
+ @this_object_context.stubs(:in_subcontext).yields(@subcontext)
25
+ @actor_view_factory.stubs(:build)
26
+ end
27
+
28
+ it 'configures the actor correctly' do
29
+ subject.build(:some_actor, @opts).should == actor
30
+ actor.foo.should == :bar
31
+ actor.actor_type.should == :some_actor
32
+ end
33
+
34
+ it 'creates the associated view class' do
35
+ @actor_view_factory.expects(:build).with(actor, @opts)
36
+ subject.build(:some_actor, @opts).should == actor
37
+ end
38
+
39
+ it "raises on actor not found" do
40
+ lambda{ subject.build :no_actor, @opts }.should raise_error(/no_actor not found/)
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,78 @@
1
+ require 'helper'
2
+ describe Actor do
3
+
4
+ subject { create_actor :actor }
5
+
6
+ it 'should be alive' do
7
+ subject.alive.should be_true
8
+ end
9
+
10
+ it 'should be the correct type' do
11
+ subject.actor_type.should == :actor
12
+ end
13
+
14
+ it 'should fire anything' do
15
+ Proc.new {
16
+ subject.when :foofoo_bar do
17
+ "blah"
18
+ end
19
+ }.should_not raise_error
20
+ end
21
+
22
+ # it 'should inherit parents behaviors' do
23
+ # @shawn = create_actor :shawn
24
+ # @shawn.is?(:smart).should be_true
25
+ # end
26
+
27
+ # it 'should be able to override parents behaviors' do
28
+ # @james = create_actor :james_kilton
29
+ # @james.is?(:smart).should be_true
30
+ # @james.instance_variable_get('@behaviors')[:smart].instance_variable_get('@opts').should == {:really=>true}
31
+ # end
32
+
33
+ describe "#add_behavior" do
34
+ it 'can add a behavior to the actors list of behaviors'
35
+ end
36
+
37
+ describe "#has_attribute" do
38
+ it 'adds an evented attribute'
39
+ end
40
+
41
+ describe "#has_attribute?" do
42
+ it 'returns true if the actor has the attribute'
43
+ it 'returns false if the actor does not have the attribute'
44
+ end
45
+
46
+ describe "#has_behavior?" do
47
+ it 'returns true if the actor has the behavior'
48
+ it 'returns false if the actor does not have the behavior'
49
+ end
50
+
51
+ describe "#emit" do
52
+ it 'allows firing of events w/ the actor as the source'
53
+ end
54
+
55
+ describe ".define" do
56
+ it 'adds an actor definition' do
57
+ Actor.define :mc_bane do |act|
58
+ act.has_behavior shooty: { bullets: 50 }
59
+ act.has_behavior :death_on_d
60
+ end
61
+
62
+ definition = Actor.definitions[:mc_bane]
63
+ definition.should be
64
+ definition.behaviors.should == [{shooty: {bullets:50}}, :death_on_d]
65
+ end
66
+ end
67
+
68
+ end
69
+ #
70
+ # class Cool < Behavior; end
71
+ # class Smart < Behavior; end
72
+ # class Coder < Actor
73
+ # has_behavior :smart, :cool
74
+ # end
75
+ # class Shawn < Coder; end
76
+ # class JamesKilton < Coder
77
+ # has_behavior :smart => {:really => true}
78
+ # end
@@ -0,0 +1,53 @@
1
+ require 'helper'
2
+
3
+ describe ActorView do
4
+
5
+ let!(:subcontext) do
6
+ it = nil
7
+ Conject.default_object_context.in_subcontext{|ctx|it = ctx};
8
+ _mocks = create_mocks *(Actor.object_definition.component_names + ActorView.object_definition.component_names - [:actor])
9
+ _mocks.each do |k,v|
10
+ it[k] = v
11
+ end
12
+ it
13
+ end
14
+ subject { subcontext[:actor_view] }
15
+ let!(:actor) { subcontext[:actor] }
16
+
17
+ it 'should be layered 0/1 by default' do
18
+ subject.layer.should == 0
19
+ subject.parallax.should == 1
20
+ end
21
+
22
+ it 'should accept layered behavior params from actor' do
23
+ actor.has_attribute :layer, 6
24
+ actor.has_attribute :parallax, 3
25
+
26
+ subject.layer.should == 6
27
+ subject.parallax.should == 3
28
+ end
29
+
30
+ # TODO move these to visible behavior spec
31
+ # it 'should register for show events' do
32
+ # @stage.expects(:register_drawable).with(subject)
33
+ # actor.react_to :show
34
+ # end
35
+
36
+ # it 'should register for hide events' do
37
+ # @stage.expects(:unregister_drawable).with(subject)
38
+ # actor.react_to :hide
39
+ # end
40
+
41
+ # it 'should register for remove events' do
42
+ # @stage.expects(:unregister_drawable).with(subject)
43
+ # actor.react_to :remove
44
+ # end
45
+
46
+ describe ".define" do
47
+ it 'should call setup on creation'
48
+ # ActorView.any_instance.expects :configure
49
+ end
50
+
51
+
52
+ it 'should manage a cached surface for drawing (possibly use record{})'
53
+ end
@@ -1,5 +1,4 @@
1
- require File.join(File.dirname(__FILE__),'helper')
2
-
1
+ require 'helper'
3
2
 
4
3
  class Arb
5
4
  include Arbiter
@@ -17,24 +16,24 @@ describe 'Arbiter' do
17
16
 
18
17
  describe '#collide?' do
19
18
  it 'should call the correct circle circle collision method' do
20
- a = stub(:collidable_shape => :circle, :is? => true)
21
- b = stub(:collidable_shape => :circle, :is? => true)
19
+ a = stub(:shape_type => :circle)
20
+ b = stub(:shape_type => :circle)
22
21
  @arbiter.expects(:collide_circle_circle?).with(a,b).returns(true)
23
22
 
24
23
  @arbiter.collide?(a,b).should be_true
25
24
  end
26
25
 
27
- it 'should call the correct circle polygon collis?ion method' do
28
- a = stub(:collidable_shape => :circle, :is? => true)
29
- b = stub(:collidable_shape => :polygon, :is? => true)
26
+ it 'should call the correct circle polygon collision method' do
27
+ a = stub(:shape_type => :circle)
28
+ b = stub(:shape_type => :polygon)
30
29
  @arbiter.expects(:collide_circle_polygon?).with(a,b).returns(true)
31
30
 
32
31
  @arbiter.collide?(a,b).should be_true
33
32
  end
34
33
 
35
- it 'should call the correct polygon circle collis?ion method' do
36
- a = stub(:collidable_shape => :polygon, :is? => true)
37
- b = stub(:collidable_shape => :circle, :is? => true)
34
+ it 'should call the correct polygon circle collision method' do
35
+ a = stub(:shape_type => :polygon)
36
+ b = stub(:shape_type => :circle)
38
37
  @arbiter.expects(:collide_circle_polygon?).with(b,a).returns(true)
39
38
 
40
39
  @arbiter.collide?(a,b).should be_true
@@ -43,33 +42,33 @@ describe 'Arbiter' do
43
42
 
44
43
  describe '#collide_circle_circle?' do
45
44
  it 'should collide overlapping circles' do
46
- a = stub(:center_x => 0, :center_y => 0, :radius => 30, :collidable_shape => :circle)
47
- b = stub(:center_x => 0, :center_y => 10, :radius => 3, :collidable_shape => :circle)
45
+ a = stub(:center_x => 0, :center_y => 0, :radius => 30, :shape_type => :circle)
46
+ b = stub(:center_x => 0, :center_y => 10, :radius => 3, :shape_type => :circle)
48
47
  @arbiter.collide_circle_circle?(a, b).should be_true
49
48
  end
50
49
 
51
50
  it 'should collide a circle in a circle' do
52
- a = stub(:center_x => 0, :center_y => 0, :radius => 30, :collidable_shape => :circle)
53
- b = stub(:center_x => 10, :center_y => 10, :radius => 30, :collidable_shape => :circle)
51
+ a = stub(:center_x => 0, :center_y => 0, :radius => 30, :shape_type => :circle)
52
+ b = stub(:center_x => 10, :center_y => 10, :radius => 30, :shape_type => :circle)
54
53
  @arbiter.collide_circle_circle?(a, b).should be_true
55
54
  end
56
55
 
57
56
  it 'should not collide non-overlapping circles' do
58
- a = stub(:center_x => 0, :center_y => 0, :radius => 30, :collidable_shape => :circle)
59
- b = stub(:center_x => 100, :center_y => 100, :radius => 30, :collidable_shape => :circle)
57
+ a = stub(:center_x => 0, :center_y => 0, :radius => 30, :shape_type => :circle)
58
+ b = stub(:center_x => 100, :center_y => 100, :radius => 30, :shape_type => :circle)
60
59
  @arbiter.collide_circle_circle?(a, b).should be_false
61
60
  end
62
61
  end
63
62
 
64
63
  describe '#collide_polygon_polygon?' do
65
64
  it 'should not collide non-overlapping polys based on radius' do
66
- a = stub(:center_x => 0, :center_y => 0, :radius => 30, :collidable_shape => :polygon)
67
- b = stub(:center_x => 61, :center_y => 0, :radius => 30, :collidable_shape => :polygon)
65
+ a = stub(:center_x => 0, :center_y => 0, :radius => 30, :shape_type => :polygon)
66
+ b = stub(:center_x => 61, :center_y => 0, :radius => 30, :shape_type => :polygon)
68
67
  @arbiter.collide_polygon_polygon?(a,b).should be_false
69
68
  end
70
69
 
71
70
  it 'should not collide non-overlapping polys based on points' do
72
- a = stub(:center_x => 0, :center_y => 0, :radius => 30, :collidable_shape => :polygon,
71
+ a = stub(:center_x => 0, :center_y => 0, :radius => 30, :shape_type => :polygon,
73
72
  :cw_world_points => [
74
73
  [0,0],[0,30], [0,30]
75
74
  ],
@@ -85,7 +84,7 @@ describe 'Arbiter' do
85
84
  ]
86
85
 
87
86
  )
88
- b = stub(:center_x => 60, :center_y => 0, :radius => 30, :collidable_shape => :polygon,
87
+ b = stub(:center_x => 60, :center_y => 0, :radius => 30, :shape_type => :polygon,
89
88
  :cw_world_points => [
90
89
  [60,0],[60,30], [90,0]
91
90
  ],
@@ -104,7 +103,7 @@ describe 'Arbiter' do
104
103
  end
105
104
 
106
105
  it 'should collide non-overlapping polys based on points' do
107
- a = stub(:center_x => 0, :center_y => 0, :radius => 30, :collidable_shape => :polygon,
106
+ a = stub(:center_x => 0, :center_y => 0, :radius => 30, :shape_type => :polygon,
108
107
  :cw_world_points => [
109
108
  [0,0],[0,30],[30,0]
110
109
  ],
@@ -119,7 +118,7 @@ describe 'Arbiter' do
119
118
  [0,-30]
120
119
  ]
121
120
  )
122
- b = stub(:center_x => 29, :center_y => 0, :radius => 30, :collidable_shape => :polygon,
121
+ b = stub(:center_x => 29, :center_y => 0, :radius => 30, :shape_type => :polygon,
123
122
  :cw_world_points => [
124
123
  [29,0],[29,30],[59,0]
125
124
  ],
@@ -138,7 +137,7 @@ describe 'Arbiter' do
138
137
  end
139
138
 
140
139
  it 'should collide completely overlapping polys based on points' do
141
- a = stub(:center_x => 0, :center_y => 0, :radius => 30, :collidable_shape => :polygon,
140
+ a = stub(:center_x => 0, :center_y => 0, :radius => 30, :shape_type => :polygon,
142
141
  :cw_world_points => [
143
142
  [0,0],[0,30],[30,0]
144
143
  ],
@@ -153,7 +152,7 @@ describe 'Arbiter' do
153
152
  [0,-30]
154
153
  ]
155
154
  )
156
- b = stub(:center_x => 2, :center_y => 0, :radius => 10, :collidable_shape => :polygon,
155
+ b = stub(:center_x => 2, :center_y => 0, :radius => 10, :shape_type => :polygon,
157
156
  :cw_world_points => [[10,0],[10,20],[20,0]],
158
157
  :cw_world_lines => [
159
158
  [10,0],[10,20],
@@ -172,8 +171,8 @@ describe 'Arbiter' do
172
171
 
173
172
  describe '#collide_circle_polygon?' do
174
173
  it 'should collide overlapping circle and polygon' do
175
- a = stub(:center_x => 0, :center_y => 0, :radius => 30, :collidable_shape => :circle)
176
- b = stub(:center_x => 2, :center_y => 0, :radius => 10, :collidable_shape => :polygon,
174
+ a = stub(:center_x => 0, :center_y => 0, :radius => 30, :shape_type => :circle)
175
+ b = stub(:center_x => 2, :center_y => 0, :radius => 10, :shape_type => :polygon,
177
176
  :cw_world_points => [[10,0],[10,20],[20,0]],
178
177
  :cw_world_lines => [
179
178
  [10,0],[10,20],
@@ -190,8 +189,8 @@ describe 'Arbiter' do
190
189
  end
191
190
 
192
191
  it 'should not collide overlapping circle and polygon' do
193
- a = stub(:center_x => 0, :center_y => 0, :radius => 30, :collidable_shape => :circle)
194
- b = stub(:center_x => 200, :center_y => 0, :radius => 10, :collidable_shape => :polygon,
192
+ a = stub(:center_x => 0, :center_y => 0, :radius => 30, :shape_type => :circle)
193
+ b = stub(:center_x => 200, :center_y => 0, :radius => 10, :shape_type => :polygon,
195
194
  :cw_world_points => [[10,0],[10,20],[20,0]],
196
195
  :cw_world_lines => [
197
196
  [208,0],[208,20],
@@ -211,7 +210,7 @@ describe 'Arbiter' do
211
210
  describe '#collide_aabb_aabb' do
212
211
  it 'should collide overlapping boxes' do
213
212
  a = stub(:center_x => 0, :center_y => 0, :width => 30, :height => 20,
214
- :collidable_shape => :aabb, :radius => 10,
213
+ :shape_type => :aabb, :radius => 10,
215
214
  :cw_world_points => [
216
215
  [-15,10],[15,10],
217
216
  [15,-10], [-15,10]
@@ -224,7 +223,7 @@ describe 'Arbiter' do
224
223
  ],
225
224
  :cw_world_edge_normals => [[1,0],[0,1]])
226
225
  b = stub(:center_x => 5, :center_y => 5, :width => 10, :height => 2,
227
- :collidable_shape => :aabb, :radius => 10,
226
+ :shape_type => :aabb, :radius => 10,
228
227
  :cw_world_points => [
229
228
  [0,6],[10,6],
230
229
  [10,4], [0,6]