You don't seem to be calling repaint
, so that component doesn't know that it should update the values...
For example...
public void addPipe() {
for (int i = 0; i < pipe.length; i++) {
if (pipe[i] == null) {
pipe[i] = new Pipe(this.width, (int) Math.random() * (this.height - 200));
System.out.println("Pipe Added.");
numPipes += 1;
}
}
repaint();
}
Now, you could place repaint
after numPipes += 1
, but because of the way repaint
works, it probably won't make a difference...
This assumes that the class that addPipe
belongs to is some kind of component, but you've not supplied enough information to make proper diagnoses...