In the code below, my images aren't displaying on the screen even though they're in the project folder and (as far as I can tell) loaded correctly into the class. I'd appreciate any advice you can give.
Thanks!
Main
void setup () {
size (400, 800);
int theo, vincent;
theo=vincent=0;
String[] lines;
lines = loadStrings("JoVanGoghMemoir.txt");
for (int k = 0; k < lines.length; k++) {
String[] words = split(lines[k], ' ');
for (int m = 0; m < words.length; m++) {
String currentWord = words[m].toLowerCase();
//println("\n" + currentWord);
if (currentWord == "Theo") {
theo ++;
}
else if (currentWord == "Vincent") {
vincent++;
}
}
}
Tstar [] theostars = new Tstar [theo];
Vstar [] vinstars = new Vstar [vincent];
for (int i=0; i < theo ; i++) {
theostars[i] = new Tstar();
theostars[i].drawastar();
}
for (int i=0; i < vincent ; i++) {
vinstars[i] = new Vstar();
vinstars[i].drawastar();
}
}
void draw ()
{
}
Tstar
class Tstar {
PImage theostar = loadImage ("theostar.gif");
float x = random (0, width);
float y = random (0, height);
float xconstrained;
float yconstrained;
Tstar() { // The Constructor is defined with arguments.
}
void drawastar ()
{
xconstrained = constrain (x, 0, (2*width)/3);
yconstrained = constrain (y, 0, height/2);
/*fill (125);
strokeWeight (1);
stroke (0);
rect (x, y, aswidth, asheight);*/
image (theostar, xconstrained, yconstrained);
}
}
Vstar
class Vstar {
PImage vinstar = loadImage ("startwo.gif");
float x = random (0, width);
float y = random (0, height);
float xconstrained;
float yconstrained;
Vstar() { // The Constructor is defined with arguments.
When I run this code, I'm getting a StringArrayIndexOutOfBounds at 2 error. While I know what this means, I'm not sure what in the code is causing it to go out of bounds.
I'm getting an error message that read "Cannot make a static reference to the non-static method drawastar() from the type VanGoghFinalProject297D.astar." I'm not sure how to fix it.