Sha256: f82054eaed901ee0ad8164cb5b04f9ee2e6c93b4883eee07d7586c7c4b42ae53

Contents?: true

Size: 752 Bytes

Versions: 1

Compression:

Stored size: 752 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 setup
  size(640,360)
  @box2d = Box2D.new(self)
  box2d.createWorld
  @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

1 entries across 1 versions & 1 rubygems

Version Path
pbox2d-0.4.2-java examples/revolute_joint/revolute_joint.rb