Sha256: e8c31b79d8cf36b0b6bf28d507225d641558f5653b5af53b90839fe638302f35

Contents?: true

Size: 587 Bytes

Versions: 3

Compression:

Stored size: 587 Bytes

Contents

require 'pbox2d'
require 'forwardable'
require_relative 'lib/custom_listener'
require_relative 'lib/particle'
require_relative 'lib/boundary'

attr_reader :box2d, :particles, :wall

def setup
  size 400, 400
  @box2d = Box2D.new(self)
  box2d.create_world
  box2d.add_listener(CustomListener.new)
  @particles = []
  @wall = Boundary.new(self, width / 2, height - 5, width, 10)
end

def draw
  col = color('#ffffff')
  background(col)
  particles << Particle.new(self, rand(width), 20, rand(4..8)) if rand < 0.1
  particles.each(&:display)
  particles.reject!(&:done)
  wall.display
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pbox2d-0.5.0-java examples/test_contact/test_contact.rb
pbox2d-0.4.1-java examples/test_contact/test_contact.rb
pbox2d-0.4.0-java examples/test_contact/test_contact.rb