ArtBIT on DeviantArthttp://creativecommons.org/licenses/by-sa/3.0/https://www.deviantart.com/artbit/art/writtenInMagic-43562296ArtBIT

Deviation Actions

ArtBIT's avatar

writtenInMagic

By
Published:
9.6K Views

Description

-NEEDS FLASH 8 OR HIGHER-

Just a small experiment, that ended up quite hypnotic...

[MouseClick] - toggles blur
[LEFT, RIGHT, UP, DOWN] - controls gravity
[SPACE] - turns off gravity
[1] - snake mode
[2] - lines mode

Trip.

Peace.

***Check out the variation inspired by this work (which is even better imo) -> [link]

[EDIT March, 18. 2007.]
Since several people asked me about the code behind this, here's the basic engine for you to experiment with:

var numPoints = 20;
var speed = 10;
var stageWidth = 550;
var stageHeight = 400;
var points:Array = generateArrayOfPoints(numPoints);

function generateArrayOfPoints(num:Number):Array {
  var arr:Array = new Array();
  for(var i=0; i<num; i++) {
    // create a new object and place it in the array
    // Objects has 4 properties: (x, y) - position vector, (vx, vy) - velocity vector
    arr.push(new Object( {x:Math.random()*stageWidth, y:Math.random()*stageHeight, vx: (Math.random()-0.5)*speed, vy: (Math.random()-0.5)*speed} ));
  }
  return arr;
}

function movePoints(arr:Array) {
  var len = arr.length;
  for(var i=0; i<len; i++) {
    var p = arr[i];
    p.x += p.vx;
   
    //check for if it left the screen   
    if( p.x>stageWidth || p.x<0 ) {
      //reverse the x velocity
      p.vx*=-1;
      p.x += p.vx;
    }
   
    p.y += p.vy;
   
    if( p.y>stageHeight || p.y<0 ) {
      //reverse the y velocity
      p.vy*=-1;
      p.y += p.vy;
    } 
   
  }
}

function plotPoints(mc:MovieClip, arr:Array) {
  mc.lineStyle(2,0xaaaaaa,100);
  var len = arr.length;
  //position the pen on our first point in the array
  mc.moveTo(arr[0].x,arr[0].y);
  //cycle through our points array
  for(var i=0; i<len; i++) {
    //plot a line to the current point
    mc.lineTo(arr[i].x,arr[i].y);
  }
}

onEnterFrame = function() {
  //clear the canvas
  this.clear();
  //calculate new positions for our array
  movePoints(points);
  //plot the lines
  plotPoints(this,points);
}
Image size
550x400px 4.27 KB
Comments126
Join the community to add your comment. Already a deviant? Log In
sallycat1304's avatar
this my party AND I DANCE FOREVER