Sha256: ec80a74607aa5461decaff56bb2c5630b520d80d13fc8ad9af9569f62d0d9ebf
Contents?: true
Size: 622 Bytes
Versions: 11
Compression:
Stored size: 622 Bytes
Contents
require 'toxiclibs' require_relative 'attractor' require_relative 'particle' attr_reader :particles, :attractor, :physics def settings size 640, 360 end def setup sketch_title "Attract Repel" @physics = Physics::VerletPhysics2D.new physics.setDrag(0.01) @particles = (0..50).map { Particle.new(TVec2D.new(rand(width), rand(height))) } @attractor = Attractor.new(TVec2D.new(width / 2, height / 2)) end def draw background(255) physics.update attractor.display particles.each(&:display) if mouse_pressed? attractor.lock attractor.set(mouse_x, mouse_y) else attractor.unlock end end
Version data entries
11 entries across 11 versions & 1 rubygems