xxxxxxxxxx
71
let width = 400;
let height = 400;
let sprites = [];
let rows,cols;
let size = 20;
function setup() {
createCanvas(width , height,WEBGL);
angleMode(DEGREES);
rectMode(CENTER);
rows = width/size;
cols = height/size;
grid();
}
function grid(){
let xstart = cos(random(10));
let xnoise = xstart;
let ynoise = random(10);
let _inc = 0.1;
translate(size,size);
for(let i=0; i < rows; i++){
ynoise += _inc;
xnoise = xstart;
for(let j=0; j < cols; j++){
xnoise += _inc;
let perlin = noise(xnoise, ynoise);
let angle = perlin * 360;
let spd = 5;
let sprite = new Sprite(size/2 + i * size,size/2 + j * size,size,angle,spd);
sprites.push(sprite);
}
}
}
function draw(){
background(255);
translate(-width * 0.5,-height * 0.5);
for(let i=0; i < sprites.length; i++){
sprites[i].display();
sprites[i].update();
}
}