I’ve been working on this for a while, but I’ve become stuck while trying to get each of the members of this class to move. Here’s the code
Table table;
void setup() {
size(500, 500);
//noStroke();
table = loadTable("goodBorrowedData.tsv", "header, tsv");
// for (int i = 0; i < table.getRowCount(); i++){
// myDancers[i] = new tinyDancer();
// }
}
void draw() {
background(0, 157);
tinyDancer[] myDancers = new tinyDancer[table.getRowCount()];
for (int r=0; r < table.getRowCount(); ++r) {
TableRow row = table.getRow(r);
//String name = row.getString(0);
float size = row.getFloat(1);
float xVal = row.getFloat(2);
float yVal = row.getFloat(4);
float extraVal = row.getFloat(3);
//println("cntry: "+name+". size: "+size+". xComp: "+xVal+". yComp:"+yVal+". extra:"+extraVal+".");
myDancers[r] = new tinyDancer(r, extraVal, size, xVal, yVal);
myDancers[r].display();
//myDancers[r].moveit();
}
for (int i=0; i < myDancers.length; i++) {
myDancers[i].moveit();
}
}
and here is the class itself
class tinyDancer {
float size;
float xPos, yPos;
float xRate, yRate;
tinyDancer(float iXPos, float iYPos, float iSize, float iXRate, float iYRate) {
xPos = map (iXPos, 0, 143, 0, width);
yPos = map (iYPos, 0, 100, 0, height); //electric access
size = map (iSize, 231, 74593901, 5, 250); //pop
xRate = map (iXRate, 0, 7005671.2, 1, 50); //methane
yRate = map (iYRate, 0.00912679, 40.310084, 1, 50); //CO2
}
void display() {
//fill(
ellipse(xPos, yPos, size, size);
}
void moveit() {
xPos += xRate;
println(xRate);
yPos += yRate;
if (xPos+size > width || xPos<0) {
xRate *= -1;
}
if (yPos+size > height || yPos < 0) {
yRate *= -1;
}
}
}
any help would be appreciated!