pbox2d 0.1.2-java → 0.2.0-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: ceb2a6aa9dc572cc3f0cf0b49c87bb2cadbf9053
4
- data.tar.gz: 6ba76695c669aa7417606b1cfb3741ddfb97a33e
3
+ metadata.gz: 3846e89a9fefd3dbf3debf52fa9e44d2b79cef81
4
+ data.tar.gz: 77ed75d1c31a43c0b40b3e5793d5860f221a4da7
5
5
  SHA512:
6
- metadata.gz: 8ddb97cbf0c590ea9ddd0f6eb9ed6e3cdda08cee429a38b77ece28693223205bd572934368ccf99acfb279a521c8fef734ff772ed13e415e0d1f3b3c8c81c733
7
- data.tar.gz: a5171696554e9c4eb7091661e0ca9a522d0997c91b26969a39d033631beff4a1d44856c212d9d7eab8e4862fe9a8eb187908891e78912f8e1fdaac89239dfdb4
6
+ metadata.gz: d48259c8cdfc9a7b8a1708c72f850fe0855bd56d88d914c62d539b797ea52ef0b2ce52ebb1c8f6a8d393925bb1dd254fbcd748a21e9b64619e0e8f9beef9b840
7
+ data.tar.gz: f954487395970a0e2b325f87fdd83d7ac9e9464441a8d7cb912c7532e00f3b4adc55bac5eb6521c1cc2c39167f23faca447e68332b992153d96b41622c9ddb3b
data/README.md CHANGED
@@ -12,6 +12,10 @@ Here we demonstrate how to use JBox2D library as a rubygem. This approach could
12
12
 
13
13
  [Box2D for processing on github][]
14
14
 
15
+ Downloads including examples [zip][] and [tar][]
16
+
17
+ [Wiki][]
18
+
15
19
  ### Licensing
16
20
 
17
21
  Daniel Murphy is currently claiming ownership of jbox2d (although surely a derived work):-
@@ -39,11 +43,11 @@ Like really easy, but if you have to use rvm or rbenv you will also know what to
39
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.
40
44
  ```ruby
41
45
  @box2d = Box2D.new(self)
42
- box2d.create_world
43
- box2d.gravity(0, -20) # to set a custom gravity
46
+ box2d.init_options(gravity: [0, -20]) # this is new since version 0.2.0
47
+ box2d.create_world
44
48
  ```
45
- That's about all you need to know, use the box2d instance to access the jbox2d physics world. Ordinarily (with jbox2d) you need to set some other parameters, and call `box2d.step` in the draw loop, to update the physics world.
46
- To make things dead simple, we have set those parameters to sensible defaults, and call `step` in the draw loop for you (under the hood using java reflection). The other thing you should know is there is a mismatch between the physics world and the sketch world (processing got it wrong to my view, down is up), further the scaling is different. This is why you need to keep translating from one worlds (coordinates) to the others coordinates, Dan Shiffman explains it in his [Nature of Code book][], Chapter 5 physics libraries, not that I've read it, I prefer to read code or [Sandi Metz][]. The really brave or adventurous should probably get [this book].
49
+ That's about all you need to know, to use the box2d instance to access the jbox2d physics world. Since version 0.2.0 runtime options `scale`, `gravity`, `warm_start`, and `continous_physics` option should be set using the `init_options` method see above (if unset sensible defaults are used). The `step_options` are set in the same way, but default options are often suitable. NB: You do not need to call `box2d.step` in the draw loop, to update the physics world, because we do that for you under the hood (using java reflection arghhh.....).
50
+ The other thing you should know is there is a mismatch between the physics world and the sketch world (processing got it wrong to my view, down is up), further the scaling is different. This is why you need to keep translating from one worlds (coordinates system) to the others coordinates (system), Dan Shiffman explains it in his [Nature of Code book][], Chapter 5 physics libraries, not that I've read it, I prefer to read code or [Sandi Metz][]. The really brave or adventurous should probably get [this book].
47
51
 
48
52
  [JBox2D Home]:http://www.jbox2d.org/
49
53
  [JBox2D on github]:https://github.com/jbox2d/jbox2d
@@ -54,3 +58,6 @@ To make things dead simple, we have set those parameters to sensible defaults, a
54
58
  [Nature of Code book]:http://natureofcode.com/
55
59
  [Sandi Metz]:http://www.poodr.com/
56
60
  [this book]:http://www.crcpress.com/product/isbn/9781466565760
61
+ [zip]:https://github.com/ruby-processing/jbox2d/archive/0.2.0.zip
62
+ [tar]:https://github.com/ruby-processing/jbox2d/archive/0.2.0.tar.gz
63
+ [Wiki]:https://github.com/ruby-processing/jbox2d/wiki
data/lib/box2d.jar CHANGED
Binary file
data/lib/pbox2d/box2d.rb CHANGED
@@ -2,6 +2,25 @@ require_relative 'version'
2
2
 
3
3
  class Box2D < Java::ProcessingBox2d::Box2DProcessing
4
4
 
5
+ def init_options(args = {})
6
+ scale = args[:scale] || 10.0
7
+ gravity = args[:gravity] || [0, -10.0]
8
+ warm = args[:warm] || true
9
+ continuous = args[:continuous] || true
10
+ set_options(scale, gravity.to_java(Java::float), warm, continuous)
11
+ end
12
+
13
+ def step_options(args = {})
14
+ time_step = args[:time_step] || 1.0 / 60
15
+ velocity = args[:velocity_iter] || 8
16
+ position = args[:position_iter] || 10
17
+ set_step(time_step, velocity, position)
18
+ end
19
+
20
+ def gravity(args)
21
+ change_gravity(args.to_java(Java::float))
22
+ end
23
+
5
24
  def version
6
25
  format("pbox2d version %s", Pbox2D::VERSION)
7
26
  end
@@ -1,3 +1,3 @@
1
1
  module Pbox2D
2
- VERSION = '0.1.2'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pbox2d
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
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-06 00:00:00.000000000 Z
11
+ date: 2014-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement