let numWalkers = 50;
let walkers = [];
let dotCanvas;
let pixelColor;
// let walkerX = [];
// let walkerY = [];
// let speed = [];
// let size = [];
let people = [];
let name = [];
let numero = 0;
function preload() {
people[0] = loadImage('george.jpg');
people[1] = loadImage('breonna.jpg');
people[2] = loadImage('ahmaud.jpg');
people[3] = loadImage('trayvon.jpg');
people[4] = loadImage('tony.jpg');
}
function setup() {
createCanvas(windowWidth, windowHeight);
background(255);
noStroke();
textAlign(CENTER, CENTER);
imageMode(CENTER);
textSize(32);
dotCanvas = createGraphics(windowWidth, windowHeight);
// for (let i = 0; i < numWalkers; i++) {
// walkerX.push(random(width));
// walkerY.push(random(height));
// speed.push(random(8, 12));
// size.push(random(12, 20));
// }
for (i = 0; i < numWalkers; i++) {
// pixelColor = people[person].get(this.x, this.y);
// dotCanvas.fill(pixelColor);
// dotCanvas.noStroke();
// dotCanvas.ellipse(walkerX[i], walkerY[i], size[i], size[i]);
// walkerX[i] += random(-speed[i], speed[i]);
// walkerY[i] += random(-speed[i], speed[i]);
// if (walkerX[i] > width) walkerX[i] = 0;
// if (walkerX[i] < 0) walkerX[i] = width / 2;
// if (walkerY[i] > height) walkerY[i] = 0;
// if (walkerY[i] < 0) walkerY[i] = height / 2;
let x = random(width);
let y = random(height);
let r = random(12, 20);
let s = random(8, 12);
let index = numero;
walkers[i] = new walker(x, y, r, s, index);
}
name[0] = 'GEORGE FLOYD';
name[1] = 'BREONNA TAYLOR';
name[2] = 'AHMAUD ARBERY';
name[3] = 'TRAYVON MARTIN';
name[4] = 'TONY MCDADE';
}
function keyPressed() {
clear();
dotCanvas.clear();
numero = numero + 1
if (numero == people.length) {
numero = 0
}
}
function draw() {
image(people[numero], width / 2, height / 2);
drawText(numero);
walker.move();
walker.show();
image(dotCanvas, width / 2, height / 2);
if (mouseIsPressed) {
// // dotCanvas.translate(mouseX, mouseY);
// let pixelColo = people[numero].get(mouseX, mouseY);
// dotCanvas.fill(pixelColo);
// dotCanvas.noStroke();
// dotCanvas.ellipse(mouseX, mouseY, 30);
dotCanvas.erase();
dotCanvas.ellipse(mouseX, mouseY, 35);
dotCanvas.noErase();
}
}
class walker {
constructor(x, y, r, s, index) {
this.x = x;
this.y = y;
this.r = r;
this.s = s;
this.index = index;
}
move() {
this.x += random(-this.s, this.s);
this.y += random(-this.s, this.s);
if (this.x > width) this.x = 0;
if (this.x < 0) this.x = width / 2;
if (this.y > height) this.y = 0;
if (this.y < 0) this.y = height / 2;
}
show() {
pixelColor = people[index].get(this.x, this.y);
dotCanvas.fill(pixelColor);
dotCanvas.noStroke();
dotCanvas.ellipse(this.x, this.y, this.r);
}
}
// function runWalker(person) {
// for (i = 0; i < walkerX.length; i++) {
// let pixelColor = people[person].get(walkerX[i], walkerY[i]);
// dotCanvas.fill(pixelColor);
// dotCanvas.noStroke();
// dotCanvas.ellipse(walkerX[i], walkerY[i], size[i], size[i]);
// walkerX[i] += random(-speed[i], speed[i]);
// walkerY[i] += random(-speed[i], speed[i]);
// if (walkerX[i] > width) walkerX[i] = 0;
// if (walkerX[i] < 0) walkerX[i] = width / 2;
// if (walkerY[i] > height) walkerY[i] = 0;
// if (walkerY[i] < 0) walkerY[i] = height / 2;
// }
// }
function drawText(person) {
fill(255);
textFont('Work Sans', width / 17);
text(name[person], width / 2, height - height / 7.5);
}
Hi can anyone tell me why I am getting a walker.move is not a function error?