hi. I want to make ‘matrix rain’ in p5js
but…
let symbols = [];
let symbolSize = 26;
function setup() {
createCanvas(window.innerWidth, window.innerHeight);
background(0);
let x = 0;
for (let i = 0; i <= width / symbolSize; i++) {
let symbol = [];
symbol = new Symbol(x, random(-1000, 0));
symbol.generateSymbols();
symbols.push(symbol);
x += symbolSize;
}
textSize(symbolSize);
}
function draw() {
background(0, 150);
symbols.forEach(function(symbol) {
symbol.render();
});
}
class Symbol {
constructor(x, y, speed) {
this.x = x;
this.y = y;
this.value='';
this.speed = speed || random(5, 20);
this.switchInterval = round(random(2, 20));
}
generateSymbols() {
this.value = String.fromCharCode(
0x30A0 + round(random(0, 96))
);
}
render() {
fill(0, 255, 70);
text(this.value, this.x, this.y);
this.rain();
if (frameCount % this.switchInterval == 0) {
this.generateSymbols();
}
}
rain() {
this.y = (this.y >= height) ? 0 : this.y += this.speed;
}
}
symbol = new Symbol(x, random(-1000, 0));
Here is an error message in the code
Why? ㅜㅜ I don’t know the reason…
TypeError: Cannot read properties of undefined (reading ‘_report’)
at undefined:2:37105
Pleas help me~~