I'm trying to make an array of objects within the class "objects"(placeholder as I don't know what to call these objects yet,) and when I try to run the program it throws two exceptions...
- ArrayOutOfBoundsException:0
- Could not run the sketch(Target VM failed to initialize)
objects[] obs;
int count;
void setup(){
fullScreen();
background(0);
textSize(70);
textAlign(CENTER);
frameRate(60);
obs = new objects[count];
int objectNumber;
int index = 0;
for(objectNumber = 0;objectNumber <=4;objectNumber++){
obs[index++] = new objects(random(0,width),random(0,height),2);
}
}
/* this is a break from the code(im skipping code that really shouldn't affect this(it doesn't call or edit the array or any previously mentioned variables*/
class objects{
float objectSpeed = 12;
float xPos;
float yPos;
objects(float tempxPos,float tempyPos, int tempSpeed){
xPos = tempxPos;
yPos = tempyPos;
objectSpeed = tempSpeed;
}
void update(){
yPos = yPos+objectSpeed;
}
void Display(){
fill(255);
ellipse(xPos,yPos,20,20);
}
}
/* more skipping in the draw block, again doesn't call or edit anything previously declared*/
function draw(){
for(objects ob : obs ){
ob.update();
ob.Display();
}
}