No interaction yet. But to grab blocks and point them onto play table and build or collage blocks of ideas, just as you do with lego or paper.
xxxxxxxxxx
var x = 0; // x position always starts at 0
var y; // y postion
var yoko; // horizontal length
var tate; // vertical length
var color_r; // r value of rgb
var color_g; // g value of rgb
var color_b; // b value of rgb
var speed; // speed. value of increment
var blocks = []; // Array of Block objects
function setup() {
createCanvas(windowWidth, windowHeight);
noStroke();
// create Block objects
// for (var i = 0; i < 2; i++) {
// blocks[i] = new Block();
// }
block = new Block();
}
function draw() {
// move blocks
// for (var i = 0; i < blocks.length; i++) {
// blocks[i].moveBlock;
// }
block.moveBlock();
}
function Block() {
// Set the ratio of horizontal-vertical length
this.yoko = random(60, 300);
this.tate = random(30, 120);
// y is given at any given height of the screen
this.y = random(windowHeight - this.tate);
this.x = x;
// set the color from 0 to 255
this.color_r = random(255);
this.color_g = random(255);
this.color_b = random(255);
// set the speed from 1 to 5
this.speed = random(1, 5);
this.moveBlock = function() {
background(255); // reset the background
// set the color
fill(this.color_r, this.color_g, this.color_b);
// draw rectangle at random position and ratio
rect(this.x, this.y, this.yoko, this.tate);
// move the rectangle from left->right
this.x += this.speed;
}
}