I'm trying to use OOP for a game, but I'm not familiar with it. So I googled for an example for constructors and found this:
http://lernprocessing.wordpress.com/2010/01/06/objekte-und-klassen/ I tried to adapt the class part to get an easy constructor for my game, but somehow it doesn't work. When I extract the part I'm interested in from the working program, it works (I deleted the stuff I didn't need):
void makeHindernisse()
{
Hindernisse [] Obstacle;
Obstacle = new Hindernisse[5];
for (int a=0; a<Obstacle.length; a++) {
float hPosx = random(10);
float hPosy = random(10);
float hHoehe = random(2);
color hFarbe = color(255,0,0);
Obstacle[a] = new Hindernisse(hPosx,hPosy,hHoehe,hFarbe);
}
}
}
If you compare the two programs, you will see they are basically the same. That's why I don't understand why it doesn't work. I've been trying to fix this problem for a long time, but I don't know what else I could do to find a solution.
Can someone help me? I would apreciate it very much.