Am I doing this correct? I read the tutoral on making Tables in p5.js, but when I try to make one it won’t run. ATM i’m trying to get a table to hold all the positions of the walls.
here main
var wall = [35];
var bs = 25;
function preload(){
wallT = loadTable('wall.csv', 'csv');
}
function setup() {
createCanvas(600, 600);
for (var i = 0; i < 25; i++){
wall[i] = new Wall(i);
}
wall[25] = new Wall(47);
var tr = wallT.getnum(0,5); // here is where i try to get a number from the table
print(tr);
}
function draw() {
background(0);
for (var i = wall.length - 1; i >= 0; i--){
wall[i].show();
}
}
here block
class Block{
constructor(n) {
this.x = n;
this.y = 0;
while (this.x > 23){
this.y += 1;
this.x -= 24;
}
this.y *= bs;
this.x *= bs;
}
}
here wall
class Wall extends Block{
constructor(n) {
super(n);
}
show(){
fill(255);
rect(this.x,this.y,bs,bs);
}
}
wall.csv
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,47
so am I trying to get the number in the table correctly or did I miss up?