We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a65fd65 commit 406a310Copy full SHA for 406a310
examples/bumpy_surface_noise.rb
@@ -37,5 +37,5 @@ def draw
37
particles.reject!(&:done)
38
# Just drawing the framerate to see how many particles it can handle
39
fill(0)
40
- text("framerate: #{frame_rate.to_i}", 12, 16)
+ text(format('framerate: %d', frame_rate), 12, 16)
41
end
examples/lib/boundary.rb
@@ -2,7 +2,7 @@
2
class Boundary
3
extend Forwardable
4
def_delegators(:@app, :fill, :stroke, :rect, :rect_mode, :box2d)
5
- attr_reader :pos, :size, :b
+ attr_reader :pos, :size, :b, :x, :y, :w, :h
6
def initialize(app, x, y, w, h)
7
@app, @x, @y, @w, @h = app, x, y, w, h
8
sd = PolygonShape.new
examples/lib/custom_shape.rb
@@ -4,9 +4,9 @@ class CustomShape
attr_reader :body, :box2d
# Constructor
- def initialize(b2d, x, y)
+ def initialize(app, x, y)
# Add the box to the box2d world
9
- @box2d = b2d
+ @box2d = app.box2d
10
make_body(Vec2.new(x, y))
11
12
examples/polygons.rb
@@ -1,6 +1,7 @@
1
# Basic example of falling rectangles
require 'pbox2d'
require_relative 'lib/custom_shape'
+require_relative 'lib/boundary'
attr_reader :box2d, :boundaries, :polygons
@@ -16,10 +17,10 @@ def setup
16
17
# Create Arrays
18
@polygons = []
19
@boundaries = [
- Boundary.new(self, width / 4, height - 5, width / 2 - 50, 10, 0),
20
- Boundary.new(self, 3 * width / 4, height - 50, width / 2 - 50, 10, 0),
21
- Boundary.new(self, width - 5, height / 2, 10, height, 0),
22
- Boundary.new(self, 5, height / 2, 10, height, 0)
+ Boundary.new(self, width / 4, height - 5, width / 2 - 50, 10),
+ Boundary.new(self, 3 * width / 4, height - 50, width / 2 - 50, 10),
+ Boundary.new(self, width - 5, height / 2, 10, height),
23
+ Boundary.new(self, 5, height / 2, 10, height)
24
]
25
26
examples/revolute_joint/revolute_joint.rb
@@ -29,7 +29,7 @@ def draw
29
system.run
30
# Draw the windmill
31
windmill.display
32
- status = windmill.motor_on? ? "ON" : "OFF"
+ status = windmill.motor_on? ? 'ON' : 'OFF'
33
34
text(format("Click mouse to toggle motor.\nMotor: %s", status), 10, height - 30)
35
examples/test_contact/lib/particle.rb
# when two particles collide (no change just hitting boundary)
class Particle
- def_delegators(:@app, :box2d, :begin_shape, :end_shape, :line, :pop_matrix,
+ def_delegators(:@app, :box2d, :begin_shape, :color, :end_shape, :line, :pop_matrix,
:ellipse, :translate, :rotate, :stroke, :push_matrix,
:fill, :no_fill, :stroke_weight)
attr_accessor :body
@@ -12,7 +12,7 @@ def initialize(app, x, y, r)
@app, @x, @y, @radius = app, x, y, r
13
# This function puts the particle in the Box2d world
14
make_body(x, y, radius)
15
- @col = -5_263_441 # grey
+ @col = color('#c0c0c0') # silver
body.setUserData(self)
@@ -23,7 +23,7 @@ def kill_body
# Change color when hit
def change
- @col = -65_536 # red
+ @col = color('#cc0000') # red
27
28
# Is the particle ready for deletion?
examples/test_contact/test_contact.rb
@@ -16,8 +16,7 @@ def setup
def draw
- col = color('#ffffff')
- background(col)
+ background(color('#ffffff'))
particles << Particle.new(self, rand(width), 20, rand(4..8)) if rand < 0.1
particles.each(&:display)
0 commit comments