Class: Box2D
- Inherits:
-
Java::ProcessingBox2d::Box2DProcessing
- Object
- Java::ProcessingBox2d::Box2DProcessing
- Box2D
- Defined in:
- lib/pbox2d/box2d.rb
Overview
rubified interface, also needed for add_listener
Instance Method Summary collapse
- #add_listener(listener) ⇒ Object
- #defaults ⇒ Object
- #gravity(args) ⇒ Object
- #init_options(args = {}) ⇒ Object
- #step_options(args = {}) ⇒ Object
- #version ⇒ Object
Instance Method Details
#add_listener(listener) ⇒ Object
31 32 33 34 |
# File 'lib/pbox2d/box2d.rb', line 31 def add_listener(listener) # in combination with field accessor we can access protected world self.world.setContactListener(listener) end |
#defaults ⇒ Object
16 17 18 |
# File 'lib/pbox2d/box2d.rb', line 16 def defaults {scale: 10.0, gravity: [0, -10], warm: true, continuous: true} end |
#gravity(args) ⇒ Object
27 28 29 |
# File 'lib/pbox2d/box2d.rb', line 27 def gravity(args) change_gravity(args.to_java(Java::float)) end |
#init_options(args = {}) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/pbox2d/box2d.rb', line 7 def (args = {}) args = defaults.merge(args) (args[:scale], args[:gravity].to_java(Java::float), args[:warm], args[:continuous] ) end |
#step_options(args = {}) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/pbox2d/box2d.rb', line 20 def (args = {}) time_step = args.fetch(:time_step, 1.0 / 60) velocity = args.fetch(:velocity_iter, 8) position = args.fetch(:position_iter, 10) set_step(time_step, velocity, position) end |
#version ⇒ Object
36 37 38 |
# File 'lib/pbox2d/box2d.rb', line 36 def version format('pbox2d version %s', Pbox2D::VERSION) end |