Class: Kawaii::PhysicsManager
- Inherits:
-
Object
- Object
- Kawaii::PhysicsManager
- Defined in:
- lib/kawaii/physics_manager.rb
Instance Attribute Summary collapse
-
#entities ⇒ Object
Returns the value of attribute entities.
-
#space ⇒ Object
Returns the value of attribute space.
Instance Method Summary collapse
- #add_physics_entity(entity) ⇒ Object
-
#initialize ⇒ PhysicsManager
constructor
A new instance of PhysicsManager.
- #remove_physics_entity(entity) ⇒ Object
Constructor Details
#initialize ⇒ PhysicsManager
Returns a new instance of PhysicsManager.
8 9 10 11 |
# File 'lib/kawaii/physics_manager.rb', line 8 def initialize @space = CP::Space.new @entities = [] end |
Instance Attribute Details
#entities ⇒ Object
Returns the value of attribute entities.
6 7 8 |
# File 'lib/kawaii/physics_manager.rb', line 6 def entities @entities end |
#space ⇒ Object
Returns the value of attribute space.
6 7 8 |
# File 'lib/kawaii/physics_manager.rb', line 6 def space @space end |
Instance Method Details
#add_physics_entity(entity) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/kawaii/physics_manager.rb', line 13 def add_physics_entity entity if entity.class == PhysicsEntity @entities.push entity entity.add_to_space @space else raise WrongTypeError, "Only PhysicsEntity and derivatives are accepted" end end |
#remove_physics_entity(entity) ⇒ Object
22 23 24 25 |
# File 'lib/kawaii/physics_manager.rb', line 22 def remove_physics_entity entity @entities.delete entity entity.remove_from_space @space end |