Hello! i try to keeping track and save the objects values in a file and next read the changes.
If i`ve only one object a printWriter works fine, becouse i read the changes over time. but with and array of differents objects, i dont kwow exactly which is the best approach to keep track every object and his respective value. im using json to save the status but its static. i need a system to read dynamic data.
i think about making one printWriter per object, but it will be very difficult next to load all this files.
anybody enligthme.
here`s an stupid sketch to work it.
ArrayList<Obj>o = new ArrayList<Obj>();
void setup() {
// Open the file from the createWriter() example
size(500, 500);
o.add(new Obj(random(width)));
o.add(new Obj(random(width)));
}
void draw() {
background(150);
for (Obj obj : o) {
obj.display();
}
}
class Obj {
float x;
float y = height/2;
float r;
Obj(float _x) {
x = _x;
}
void display() {
ellipse(x, y*sin(r), 10, 10);
r+=0.01;
}
}