Hey,
I've made following code, that should generate objects seperated from each other. As you can see, I made it to be minimum 200pixels away. But it seems like it means nothing the java and usually these are generated one on the another, and if not, then really close to each other. What am i doing wrong?
public void generateBeam()
{
beamXposition = new int[10];
if (beamCount == 0)
{
addObject(new Beam(), 50, 500);
beamXposition[0] = 50;
beamCount++;
}
else
{
int newXpos = beamXposition[beamCount-1] + getRandomNumber(200, 300);
beamXposition[beamCount] = newXpos;
addObject(new Beam(), newXpos, 500);
beamCount++;
}
}
public int getRandomNumber(int start, int end)
{
int number = Greenfoot.getRandomNumber(end-start);
return number+start;
}