Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removes stagehands

* Was broken / unused metaphor, replace by Conject
  • Loading branch information...
commit adf476f271a3951d85209dbc2f617075e7e9b7c7 1 parent d618e62
@shawn42 authored
View
2  lib/gamebox.rb
@@ -26,7 +26,7 @@ def log(output, level = :debug)
require "#{GAMEBOX_PATH}/version.rb"
require 'require_all'
-directory_load_order = %w(lib core post_setup_handlers actors behaviors views stagehands)
+directory_load_order = %w(lib core post_setup_handlers actors behaviors views)
directory_load_order.each do |dir|
require_all "#{GAMEBOX_PATH}/#{dir}/**/*.rb"
end
View
9 lib/gamebox/core/arbiter.rb
@@ -3,11 +3,15 @@ module Arbiter
attr_reader :checks, :collisions
def register_collidable(actor)
- stagehand(:spatial_tree).add(actor)
+ aabb_tree.add(actor)
end
def unregister_collidable(actor)
- stagehand(:spatial_tree).remove(actor)
+ aabb_tree.remove(actor)
+ end
+
+ def aabb_tree
+ @aabb_tree ||= SpatialTree.new(self)
end
def on_collision_of(first_objs, second_objs, &block)
@@ -59,7 +63,6 @@ def interested_in_collision_of?(type1, type2)
end
def find_collisions
- aabb_tree = stagehand(:spatial_tree)
collidable_actors = aabb_tree.moved_items.values
collisions = {}
View
7 ...ebox/stagehands/spatial_tree_stagehand.rb → lib/gamebox/core/spatial_tree.rb
@@ -1,10 +1,11 @@
-class SpatialTreeStagehand < Stagehand
+class SpatialTree
extend Forwardable
def_delegators :@tree, :calculate_bb, :to_s, :each, :collisions, :query, :valid?
- attr_reader :moved_items
+ attr_reader :moved_items, :stage
- def setup
+ def initialize(stage)
+ @stage
@dead_actors = {}
@moved_items = {}
@tree = AABBTree.new
View
13 lib/gamebox/core/stage.rb
@@ -14,7 +14,6 @@ class Stage
def configure(backstage, opts)
viewport.reset
- @stagehands = {}
@backstage = backstage
@opts = opts
renderer.clear_drawables
@@ -58,9 +57,6 @@ def draw(target)
def update(time)
director.update time
viewport.update time
- @stagehands.each do |name, stagehand|
- stagehand.update time
- end
find_collisions
timer_manager.update time
end
@@ -107,10 +103,6 @@ def unpause
@paused = true
end
- def stagehand(stagehand_sym, opts={})
- @stagehands[stagehand_sym] ||= create_stagehand(stagehand_sym, opts)
- end
-
# pauses the current stage, creates an actor using args, unpauses on actor death
#
# Example:
@@ -129,11 +121,6 @@ def modal_actor(*args)
end
private
- def create_stagehand(name, opts)
- underscored_class = "#{name}_stagehand"
- klass = ClassFinder.find underscored_class
- klass.new self, opts
- end
class << self
View
14 lib/gamebox/core/stagehand.rb
@@ -1,14 +0,0 @@
-class Stagehand
- attr_accessor :opts, :stage
- def initialize(stage, opts)
- @stage = stage
- @opts = opts
- setup
- end
-
- def setup
- end
-
- def update(time)
- end
-end
View
39 lib/gamebox/data/config/objects.yml
@@ -1,39 +0,0 @@
-game:
- compose:
- - wrapped_screen
- - input_manager
- - sound_manager
- - stage_manager
-resource_manager:
- auto_require: false
- compose:
- - wrapped_screen
-stage_manager:
- auto_require: false
- compose:
- - input_manager
- - resource_manager
- - sound_manager
- - config_manager
- - actor_factory
-sound_manager:
- auto_require: false
- compose:
- - resource_manager
- - config_manager
-input_manager:
- auto_require: false
- compose:
- - wrapped_screen
- - config_manager
-wrapped_screen:
- auto_require: false
- compose:
- - config_manager
-config_manager:
- auto_require: false
-actor_factory:
- auto_require: false
- compose:
- - input_manager
- - wrapped_screen
View
2  script/perf_aabb.rb
@@ -27,7 +27,7 @@ def bb
NUM = 1_000
Benchmark.bm(60) do |b|
b.report("full") do
- tree = SpatialTreeStagehand.new :thing, :thing
+ tree = SpatialTree.new :thing
thing = BoxedActor.new 1, 2, 3, 4
tree.add thing
View
4 ...stagehands/spatial_tree_stagehand_spec.rb → spec/core/spatial_tree_spec.rb
@@ -1,7 +1,7 @@
require 'helper'
-describe SpatialTreeStagehand do
- subject { SpatialTreeStagehand.new :stage, {} }
+describe SpatialTree do
+ subject { SpatialTree.new :stage }
let(:tree) { stub('tree') }
before do
View
1  spec/core/stage_spec.rb
@@ -53,7 +53,6 @@
subject.update(:time)
end
- it 'updates stagehands'
it 'checks for collisions'
end

0 comments on commit adf476f

Please sign in to comment.
Something went wrong with that request. Please try again.