-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsketch.js
34 lines (29 loc) · 830 Bytes
/
sketch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var grid = [];
var gw = 10;
function setup() {
background(255);
createCanvas(600, 600);
console.log(grid);
for (var x = 0; x * gw < width; x ++) {
grid[x] = [];
}
for (var x = 0; x * gw < width; x ++) {
for (var y = 0; y * gw < height; y ++) {
grid[x][y] = new Grid(x * gw, y * gw, 0);
}
}
for (var i = 0; i < 100; i ++) {
var ranx = random(1, grid.length);
var rany = random(1, grid[floor(ranx)].length);
grid[floor(ranx)][floor(rany)].on = 1;
console.log(grid[floor(ranx)][floor(rany)].on);
}
}
function draw() {
for (var x = 1; x < grid.length - 1; x ++) {
for (var y = 1; y < grid[x].length - 1; y ++) {
grid[x][y].show();
grid[x][y].update(grid);
}
}
}