pbox2d 0.3.0-java → 0.3.1-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bcf4d4f72a18e164769d8b310f0f421c49571b2f
4
- data.tar.gz: 390e73409881fd369a7c5e772b4ee9cb4c5a755b
3
+ metadata.gz: 804efe16e11649eda15f47f166687f533b01bb13
4
+ data.tar.gz: 21eacf2bd1015bc7a5029d95a6e5a9cc4d3a50ef
5
5
  SHA512:
6
- metadata.gz: d8ae8ae1807f9e390e1ac79ba70d0835273e36f756ac5c7047130b1d122309013bb35ed0dbfef58601a7dcee0e170f6e913d721edb02b18a11d5fdaf907a4490
7
- data.tar.gz: ff1c7997fa62935c1d616466ad0134483f8aa15227b4534c7afaf8efeff19e86a26d8e4720b103d33669a447e8f238941314755885179753ceb04fe8b15cae8f
6
+ metadata.gz: a703df8b21385e2d880141d34d2ac8b5ed6d9566512b694ff05c0720ab3c948fb0ea3e7e128dc49eee8be87b6824e14b7ca95ac5f9387763733994bdb43f7f79
7
+ data.tar.gz: 01e4749137f5f863d8d7327a45dd231eca1becf2591661ca0b49973aa257aa1283019a7754a223ac069bea54cf0726ede70f47948b649a18db9b92773c2efa65
data/README.md CHANGED
@@ -40,7 +40,7 @@ Like really easy, but if you have to use rvm or rbenv you will also know what to
40
40
 
41
41
  ### To use
42
42
 
43
- You need to `require 'pbox2d'` in the the usual way (to require a gem) but as in the included [examples][] you must also `include ContactListener` interface (by [jruby magic], including the interface as a module implements the java interface). Now you should create a new instance of Box2D.
43
+ You need to `require 'pbox2d'` in the the usual way (to require a gem). Now you should create a new instance of Box2D. However as in the included [example][] you must also `include ContactListener` interface (by [jruby magic][], including the interface as a module implements the java interface) if you wish to create your own jbox2d listener.
44
44
  ```ruby
45
45
  @box2d = Box2D.new(self)
46
46
  box2d.init_options(gravity: [0, -20]) # this is new since version 0.2.0
@@ -53,7 +53,7 @@ The other thing you should know is there is a mismatch between the physics world
53
53
  [JBox2D on github]:https://github.com/jbox2d/jbox2d
54
54
  [Box2D for processing on github]:https://github.com/shiffman/Box2D-for-Processing
55
55
  [JRubyArt]:https://github.com/ruby-processing/JRubyArt
56
- [examples]:https://github.com/ruby-processing/jbox2d/blob/master/examples/liquidy.rb
56
+ [example]:https://github.com/ruby-processing/jbox2d/blob/master/examples/test_contact/lib/custom_listener.rb
57
57
  [jruby magic]:https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby
58
58
  [Nature of Code book]:http://natureofcode.com/
59
59
  [Sandi Metz]:http://www.poodr.com/
data/lib/box2d.jar CHANGED
Binary file
data/lib/pbox2d.rb CHANGED
@@ -4,6 +4,7 @@ Dir[File.join(working_directory, '*.jar')].each do |jar|
4
4
  require jar
5
5
  end
6
6
 
7
+ # This module allows package access to the wrapped java packages
7
8
  module PB
8
9
  include_package 'org.jbox2d.collision.shapes'
9
10
  include_package 'org.jbox2d.common'
@@ -13,13 +14,13 @@ module PB
13
14
  end
14
15
 
15
16
  ContactListener = Java::OrgJbox2dCallbacks::ContactListener
16
- Transform = PB::Transform
17
- Vec2 = PB::Vec2
18
- Body = PB::Body
19
- BodyDef = PB::BodyDef
17
+ Transform = PB::Transform
18
+ Vec2 = PB::Vec2
19
+ Body = PB::Body
20
+ BodyDef = PB::BodyDef
20
21
  BodyType = PB::BodyType
21
- World = PB::World
22
- Joint = PB::Joint
22
+ World = PB::World
23
+ Joint = PB::Joint
23
24
  JointDef = PB::JointDef
24
25
  FixtureDef = PB::FixtureDef
25
26
  PolygonShape = PB::PolygonShape
data/lib/pbox2d/box2d.rb CHANGED
@@ -1,20 +1,26 @@
1
- require_relative 'version'
2
-
1
+ require_relative 'version'
2
+ # Ruby version of java wrapper allows us to have more
3
+ # rubified interface, also needed for add_listener
3
4
  class Box2D < Java::ProcessingBox2d::Box2DProcessing
4
5
  field_accessor :world # allow access to protected variable
5
6
 
6
7
  def init_options(args = {})
7
- scale = args[:scale] || 10.0
8
- gravity = args[:gravity] || [0, -10.0]
9
- warm = args[:warm] || true
10
- continuous = args[:continuous] || true
11
- set_options(scale, gravity.to_java(Java::float), warm, continuous)
8
+ args = defaults.merge(args)
9
+ set_options(args[:scale],
10
+ args[:gravity].to_java(Java::float),
11
+ args[:warm],
12
+ args[:continuous]
13
+ )
14
+ end
15
+
16
+ def defaults
17
+ {scale: 10.0, gravity: [0, -10], warm: true, continuous: true}
12
18
  end
13
19
 
14
20
  def step_options(args = {})
15
- time_step = args[:time_step] || 1.0 / 60
16
- velocity = args[:velocity_iter] || 8
17
- position = args[:position_iter] || 10
21
+ time_step = args.fetch(:time_step, 1.0 / 60)
22
+ velocity = args.fetch(:velocity_iter, 8)
23
+ position = args.fetch(:position_iter, 10)
18
24
  set_step(time_step, velocity, position)
19
25
  end
20
26
 
@@ -25,9 +31,9 @@ class Box2D < Java::ProcessingBox2d::Box2DProcessing
25
31
  def add_listener(listener)
26
32
  # in combination with field accessor we can access protected world
27
33
  self.world.setContactListener(listener)
28
- end
34
+ end
29
35
 
30
36
  def version
31
- format("pbox2d version %s", Pbox2D::VERSION)
37
+ format('pbox2d version %s', Pbox2D::VERSION)
32
38
  end
33
39
  end
@@ -1,3 +1,4 @@
1
+ # Module here just to keep namespace tidy
1
2
  module Pbox2D
2
- VERSION = '0.3.0'
3
+ VERSION = '0.3.1'
3
4
  end
metadata CHANGED
@@ -1,19 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pbox2d
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: java
6
6
  authors:
7
7
  - Martin Prout
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-13 00:00:00.000000000 Z
11
+ date: 2014-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - ~>
17
+ - !ruby/object:Gem::Version
18
+ version: '2.6'
19
+ - - '>='
17
20
  - !ruby/object:Gem::Version
18
21
  version: 2.6.4
19
22
  name: ruby-processing
@@ -22,6 +25,9 @@ dependencies:
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '2.6'
30
+ - - '>='
25
31
  - !ruby/object:Gem::Version
26
32
  version: 2.6.4
27
33
  - !ruby/object:Gem::Dependency