problem with updating positions from text file
in
Core Library Questions
•
1 year ago
I wrote a code that ireads positions from a txt file and update them to draw an object , it just goes through half of the txt file , and gives me this error too :
Smooth level 2 is not supported by the hardware. Using 0 instead.
here is the code :
import processing.opengl.*;
String[] lines;
int index = 0;
Car myCar1;
Car myCar2;
void setup() {
size(screenWidth, screenHeight,OPENGL);
background(255);
myCar1 = new Car(color(108,87,229));
myCar2 = new Car(color(116, 193, 206));
lines = loadStrings("positionss.txt");
}
void draw() {
myCar1.Move();
myCar2.display();
}
class Car {
color c;
int z = 10;
int t = 30;
Car(color tempC){
c = tempC;
}
void display() {
fill(162, 211, 172);
rect(200,65,10,30);
}
void Move() {
fill(c);
if (index < lines.length) {
background(255);
String[] pieces = split(lines[index], '\t');
if (pieces.length == 2) {
int x = int(pieces[0]);
int y = int(pieces[1]);
rect(x, y, z, t);
}
// Go to the next line for the next run through draw()
index = index + 1;
}
}
}
1