Sha256: 27bc8a7f19a759daafa57b9a9d2f62fc25f51587413b5809c48484262bbe3abe

Contents?: true

Size: 798 Bytes

Versions: 8

Compression:

Stored size: 798 Bytes

Contents

# The Nature of Code
# Daniel Shiffman
# http://natureofcode.com

# Example demonstrating revolute joint
require 'pbox2d'
require_relative 'windmill'
require_relative 'particle'
require_relative 'particle_system'

attr_reader :box2d, :windmill, :system

def settings
  size(640, 360)
end

def setup
  sketch_title 'Revolute Joint'
  @box2d = WorldBuilder.build(app: self)
  @windmill = Windmill.new(width / 2, 175)
  @system = ParticleSystem.new
end

# Click the mouse to turn on or off the motor
def mouse_pressed
  windmill.toggle_motor
end

def draw
  background(255)
  system.add_particles(width)
  system.run
  # Draw the windmill
  windmill.display
  status = windmill.motor_on? ? 'ON' : 'OFF'
  fill(0)
  text(format("Click mouse to toggle motor.\nMotor: %s", status), 10, height - 30)
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pbox2d-1.0.3-java examples/revolute_joint/revolute_joint.rb
pbox2d-1.0.2-java examples/revolute_joint/revolute_joint.rb
pbox2d-1.0.1-java examples/revolute_joint/revolute_joint.rb
pbox2d-1.0.0-java examples/revolute_joint/revolute_joint.rb
pbox2d-0.9.1-java examples/revolute_joint/revolute_joint.rb
pbox2d-0.9.0-java examples/revolute_joint/revolute_joint.rb
pbox2d-0.8.0-java examples/revolute_joint/revolute_joint.rb
pbox2d-0.6.0-java examples/revolute_joint/revolute_joint.rb