How to use burner - 10 common examples

To help you get started, we’ve selected a few burner examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vinceallenvince / FloraJS / test / mover.js View on Github external
Burner.System.setup(function() { // add your new object to the system
    this.add('World', {
      el: document.getElementById('world'),
      width: 400,
      height: 300,
      gravity: new Burner.Vector(0.3, 1)
    });
    obj = this.add('Mover');

    obj.step();
    t.equal(parseInt(obj.angle.toPrecision(2)), 73, 'pointToDirection angle.');
  });
github vinceallenvince / FloraJS / test / dragger.js View on Github external
Burner.System.setup(function() { // add your new object to the system
    this.add('World', {
      el: document.getElementById('world'),
      width: 400,
      height: 300
    });
    obj = this.add('Dragger', {
      location: new Burner.Vector(100, 100)
    });
    var item = this.add('Item', {
      location: new Burner.Vector(101, 101),
      velocity: new Burner.Vector(0, 1.5)
    });
    this.add('Dragger');
    var force = obj.drag(item); // TODO: fix

    t.equal(parseFloat(force.x.toPrecision(3)), 0, 'drag() returns force.x.');
    t.equal(parseFloat(force.y.toPrecision(3)), -2.25, 'drag() returns force.y.');

  });
github vinceallenvince / FloraJS / src / walker.js View on Github external
Walker.prototype.applyAdditionalForces = function() {

  // walker use either perlin noise or random walk
  if (this.perlin) {

    this.perlinTime += this.perlinSpeed;

    if (this.remainsOnScreen) {
      this.acceleration = new Vector();
      this.velocity = new Vector();
      this.location.x =  Utils.map(SimplexNoise.noise(this.perlinTime + this.perlinOffsetX, 0), -1, 1, 0, this.world.width);
      this.location.y =  Utils.map(SimplexNoise.noise(0, this.perlinTime + this.perlinOffsetY), -1, 1, 0, this.world.height);
    } else {
      this.acceleration.x =  Utils.map(SimplexNoise.noise(this.perlinTime + this.perlinOffsetX, 0), -1, 1, this.perlinAccelLow, this.perlinAccelHigh);
      this.acceleration.y =  Utils.map(SimplexNoise.noise(0, this.perlinTime + this.perlinOffsetY), -1, 1, this.perlinAccelLow, this.perlinAccelHigh);
    }
    return;
  }

  // point to a random angle and move toward it
  this._randomVector.x = 1;
  this._randomVector.y = 1;
  this._randomVector.normalize();
  this._randomVector.rotate(Utils.degreesToRadians(Utils.getRandomNumber(0, 359)));
  this._randomVector.mult(this.maxSpeed);
  this.applyForce(this._randomVector);
github vinceallenvince / FloraJS / src / Sensor.js View on Github external
this.onDestroy = options.onDestroy || null;
  this.rangeDisplayBorderStyle = options.rangeDisplayBorderStyle || false;
  this.rangeDisplayBorderDefaultColor = options.rangeDisplayBorderDefaultColor || false;
  this.parent = options.parent || null;
  this.displayRange = !!options.displayRange;
  if (this.displayRange) {
    this.rangeDisplay = System.add('RangeDisplay', {
      sensor: this,
      rangeDisplayBorderStyle: this.rangeDisplayBorderStyle,
      rangeDisplayBorderDefaultColor: this.rangeDisplayBorderDefaultColor
    });
  }
  this.displayConnector = !!options.displayConnector;

  this.activationLocation = new Vector();
  this._force = new Vector(); // used as a cache Vector
  this.visibility = 'hidden';
};
github vinceallenvince / FloraJS / src / sensor.js View on Github external
this.onDestroy = options.onDestroy || null;
  this.rangeDisplayBorderStyle = options.rangeDisplayBorderStyle || false;
  this.rangeDisplayBorderDefaultColor = options.rangeDisplayBorderDefaultColor || false;
  this.parent = options.parent || null;
  this.displayRange = !!options.displayRange;
  if (this.displayRange) {
    this.rangeDisplay = System.add('RangeDisplay', {
      sensor: this,
      rangeDisplayBorderStyle: this.rangeDisplayBorderStyle,
      rangeDisplayBorderDefaultColor: this.rangeDisplayBorderDefaultColor
    });
  }
  this.displayConnector = !!options.displayConnector;

  this.activationLocation = new Vector();
  this._force = new Vector(); // used as a cache Vector
  this.visibility = 'hidden';
};
github vinceallenvince / FloraJS / src / agent.js View on Github external
if (!sensorActivated && this.motorSpeed) {
    this.motorDir.x = this.velocity.x;
    this.motorDir.y = this.velocity.y;
    this.motorDir.normalize();
    if (this.velocity.mag() > this.motorSpeed) { // decelerate to defaultSpeed
      this.motorDir.mult(-this.motorSpeed);
    } else {
      this.motorDir.mult(this.motorSpeed);
    }
    this.applyForce(this.motorDir); // constantly applies a force
  }

  // TODO: cache a vector for new location
  if (this.followMouse) { // follow mouse
    var t = {
      location: new Vector(System.mouse.location.x,
          System.mouse.location.y)
    };
    this.applyForce(this._seek(t));
  }

  if (this.seekTarget) { // seek target
    this.applyForce(this._seek(this.seekTarget));
  }

  if (this.flowField) { // follow flow field
    var res = this.flowField.resolution,
      col = Math.floor(this.location.x/res),
      row = Math.floor(this.location.y/res),
      loc, target;

    if (this.flowField.field[col]) {
github vinceallenvince / FloraJS / test / sensor.js View on Github external
Burner.System.setup(function() {
    var world = this.add('World', {
      el: document.getElementById('world'),
      width: 400,
      height: 300
    });
    agent = this.add('Agent', {
      location: new Burner.Vector(190, 140)
    });
    sensor = this.add('Sensor', {
      parent: agent,
      type: 'heat',
      location: new Burner.Vector(200, 150),
      offsetDistance: 0
    });
  });
github vinceallenvince / FloraJS / test / agent.js View on Github external
Burner.System.setup(function() {
    this.add('World', {
      el: document.getElementById('world'),
      width: 400,
      height: 300
    });
    obj = this.add('Agent', {
      seekTarget: {
        location: new Burner.Vector(300, 200)
      }
    });
  });
github vinceallenvince / FloraJS / test / sensor.js View on Github external
Burner.System.setup(function() {
    var world = this.add('World', {
      el: document.getElementById('world'),
      width: 400,
      height: 300
    });
    agent = this.add('Agent', {
      location: new Burner.Vector(190, 140)
    });
    sensor = this.add('Sensor', {
      parent: agent,
      type: 'heat',
      location: new Burner.Vector(200, 150),
      offsetDistance: 0
    });
  });
github vinceallenvince / Bit-Shadow-Machine / test / item.js View on Github external
System.setup(function() {
    var world = this.add('World', {
      el: document.getElementById('world'),
      width: 400,
      height: 300
    });
    obj = this.add('Item', {
      location: new Vector(initX, initY),
      beforeStep: function() {before = 150;},
      afterStep: function() {after = 300;}
    });
  });
  obj.step();

burner

A DOM-based rendering engine.

MIT
Latest version published 10 years ago

Package Health Score

42 / 100
Full package analysis

Popular burner functions