The purpose of this is to have bouncing balls that bounce off the walls and each other. Now when I try to get them to bounce off eachother I keep getting a NullPointerExeception Error.
This is my code -
int num = 9;
int numTarget = 9;
Target[] target = new Target[numTarget];
void setup() {
size(500, 500);
frameRate(30);
PFont font;
font = loadFont("AlBayan-48.vlw");
textFont(font);
Target t1 = new Target(150, 150, 5, 1, 1);
Target t2 = new Target(150, 300, 5, 1, 1);
Target t3 = new Target(150, 450, 5, 1, 1);
Target t4 = new Target(300, 150, 5, 1, 1);
Target t5 = new Target(300, 300, 5, 1, 1);
Target t6 = new Target(300, 450, 5, 1, 1);
Target t7 = new Target(450, 150, 5, 1, 1);
Target t8 = new Target(450, 300, 5, 1, 1);
Target t9 = new Target(450, 450, 5, 1, 1);
}
void draw() {
background(0);
for (int i = 1; i < numTarget; i++) {
target[i].update();//-----------------------------This is where the error message appears.
target[i].move();
target[i].collision();
target[i].display();
}
}
class Target {
float xpos;
float ypos;
float speed;
float xdir;
float ydir;
Target (float x, float y, float s, float d, float c) {