Skip to content

Instantly share code, notes, and snippets.

Vince Allen foldi

Block or report user

Report or block foldi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
foldi /
Last active Sep 27, 2016
FloraJS | Sheep vs. Wolves

IMPORTANT: If the simulation above does not render correctly, click 'open in a new window'.

FloraJS | Sheep vs. Wolves

This simulation uses a custom Animal class that carries a custom sensor. One group, the Sheep, carries a Wolf sensor that triggers a COWARD behavior. The other group, the Wolves, carries a Sheep sensor that triggers an AGGRESSIVE behavior.

The result... the wolves chase the sheep. To make things fair, the sheep have a 'wrapWorldEdges' property set to true. When they cross the world boundary, they cross to the other side. Wolves however bounce off the world boundary.

Play with the various properties to affect the simulation.

foldi / Burner.min.css
Last active Dec 30, 2015
FloraJS | Multiple agents: followMouse and seekTarget
View Burner.min.css
/*! Burner v2.1.4 - 2013-09-16 07:09:49
Vince Allen |Brooklyn, NY | | @vinceallenvince | License: MIT */
View gist:6828805
colors = {
empty: 0,
brown: 1,
green: 2,
blue: 3,
cyan: 4,
magenta: 5,
yellow: 6,
black: 7,
gray: 8
foldi /
Last active Dec 19, 2015
SimpleSim Step 11

Step 11

  • Adds mouse input to control World gravity.
foldi /
Last active Dec 19, 2015
SimpleSim step 10

Step 10

  • Add pause, reset and step forward playback controls.
  • Add camera control.
foldi /
Last active Dec 19, 2015
SimpleSim step 9

Step 9

  • Add a resize event and handler to System.
  • Add a devicemotion event and handler for mobile browsers.
  • Update Item.step() to limit item velocity.
  • Add 'bounciness' property to Item.
  • Extend SimpleSim.Item to custom objects (Pebble and Boulder).
  • Add 'borderRadius' property to Item to render round objects.
  • Add 'angle' property to Item to render rotation.
foldi /
Last active Mar 3, 2018
SimpleSim step 8

Step 8

  • Add applyForce() function to Item and update Item.step().
  • Add 'wind' and 'thermal' properties to World.
  • Add 'mass' property to Item.
  • Add Item.checkWorldEdges() function to keep items inside browser viewport.
  • Use a cache vector in Item.applyForce() as an optimization.
foldi /
Last active Dec 19, 2015
SimpleSim step 7

Step 7

  • Add Vector library.
  • Add acceleration property to Item.
  • Add velocity property to Item.
foldi / vector.js
Last active Dec 19, 2015
SimpleSim Vector
View vector.js
(function(exports) {
* Creates a new Vector.
* @param {number} [opt_x = 0] The x location.
* @param {number} [opt_y = 0] The y location.
* @constructor
function Vector(opt_x, opt_y) {
foldi /
Last active Dec 19, 2015
SimpleSim step 6

Step 6

  • Add style rules in main.css
  • Use modernizr to detect css transforms support.
  • Create a css text string to use for positioning items.
You can’t perform that action at this time.