Skip to content

Commit 406a310

Browse files
author
monkstone
committed
tested examples
1 parent a65fd65 commit 406a310

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

examples/bumpy_surface_noise.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ def draw
3737
particles.reject!(&:done)
3838
# Just drawing the framerate to see how many particles it can handle
3939
fill(0)
40-
text("framerate: #{frame_rate.to_i}", 12, 16)
40+
text(format('framerate: %d', frame_rate), 12, 16)
4141
end

examples/lib/boundary.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
class Boundary
33
extend Forwardable
44
def_delegators(:@app, :fill, :stroke, :rect, :rect_mode, :box2d)
5-
attr_reader :pos, :size, :b
5+
attr_reader :pos, :size, :b, :x, :y, :w, :h
66
def initialize(app, x, y, w, h)
77
@app, @x, @y, @w, @h = app, x, y, w, h
88
sd = PolygonShape.new

examples/lib/custom_shape.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ class CustomShape
44
attr_reader :body, :box2d
55

66
# Constructor
7-
def initialize(b2d, x, y)
7+
def initialize(app, x, y)
88
# Add the box to the box2d world
9-
@box2d = b2d
9+
@box2d = app.box2d
1010
make_body(Vec2.new(x, y))
1111
end
1212

examples/polygons.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Basic example of falling rectangles
22
require 'pbox2d'
33
require_relative 'lib/custom_shape'
4+
require_relative 'lib/boundary'
45

56
attr_reader :box2d, :boundaries, :polygons
67

@@ -16,10 +17,10 @@ def setup
1617
# Create Arrays
1718
@polygons = []
1819
@boundaries = [
19-
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)
20+
Boundary.new(self, width / 4, height - 5, width / 2 - 50, 10),
21+
Boundary.new(self, 3 * width / 4, height - 50, width / 2 - 50, 10),
22+
Boundary.new(self, width - 5, height / 2, 10, height),
23+
Boundary.new(self, 5, height / 2, 10, height)
2324
]
2425
end
2526

examples/revolute_joint/revolute_joint.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def draw
2929
system.run
3030
# Draw the windmill
3131
windmill.display
32-
status = windmill.motor_on? ? "ON" : "OFF"
32+
status = windmill.motor_on? ? 'ON' : 'OFF'
3333
fill(0)
3434
text(format("Click mouse to toggle motor.\nMotor: %s", status), 10, height - 30)
3535
end

examples/test_contact/lib/particle.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# when two particles collide (no change just hitting boundary)
33
class Particle
44
extend Forwardable
5-
def_delegators(:@app, :box2d, :begin_shape, :end_shape, :line, :pop_matrix,
5+
def_delegators(:@app, :box2d, :begin_shape, :color, :end_shape, :line, :pop_matrix,
66
:ellipse, :translate, :rotate, :stroke, :push_matrix,
77
:fill, :no_fill, :stroke_weight)
88
attr_accessor :body
@@ -12,7 +12,7 @@ def initialize(app, x, y, r)
1212
@app, @x, @y, @radius = app, x, y, r
1313
# This function puts the particle in the Box2d world
1414
make_body(x, y, radius)
15-
@col = -5_263_441 # grey
15+
@col = color('#c0c0c0') # silver
1616
body.setUserData(self)
1717
end
1818

@@ -23,7 +23,7 @@ def kill_body
2323

2424
# Change color when hit
2525
def change
26-
@col = -65_536 # red
26+
@col = color('#cc0000') # red
2727
end
2828

2929
# Is the particle ready for deletion?

examples/test_contact/test_contact.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ def setup
1616
end
1717

1818
def draw
19-
col = color('#ffffff')
20-
background(col)
19+
background(color('#ffffff'))
2120
particles << Particle.new(self, rand(width), 20, rand(4..8)) if rand < 0.1
2221
particles.each(&:display)
2322
particles.reject!(&:done)

0 commit comments

Comments
 (0)