pbox2d 0.3.0-java → 0.3.1-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/box2d.jar +0 -0
- data/lib/pbox2d.rb +7 -6
- data/lib/pbox2d/box2d.rb +18 -12
- data/lib/pbox2d/version.rb +2 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 804efe16e11649eda15f47f166687f533b01bb13
|
4
|
+
data.tar.gz: 21eacf2bd1015bc7a5029d95a6e5a9cc4d3a50ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
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
|
-
[
|
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
|
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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
16
|
-
velocity = args
|
17
|
-
position = args
|
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(
|
37
|
+
format('pbox2d version %s', Pbox2D::VERSION)
|
32
38
|
end
|
33
39
|
end
|
data/lib/pbox2d/version.rb
CHANGED
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.
|
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
|
+
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
|