I'm fairly new to this, but I've created a game that starts by randomly spawning the actors (20 stars, which the player has to "eat", and 10 monsters which the player has to avoid). The problem is that sometimes the stars and monsters will spawn so close together that it is too difficult for the player to win. I'm thinking I have to use getObjectsInRange but I'm not sure how to use it because it will be a list- and how I will do that for each object. If anyone could at least point me in the right direction, I'd appreciate it!
Oh, also, the stars/monsters don't move. They just disappear when eaten.
This is where I added them to the game. Not sure if I can just add something inside the for loops maybe- like check each object to see if the list in getObjectsinRange has zero elements and if it doesn't, remove those objects and decrement the for loop that number of times so they will respawn. I'm just not sure how to write out the code for each object that is created because they are all new Star() or new Monster().
for(int i = 0; i<20; i++){
addObject(new Star(), Greenfoot.getRandomNumber(580)+10,Greenfoot.getRandomNumber(380)+10);
}
for(int j=0; j<10; j++){
addObject(new Monster(), Greenfoot.getRandomNumber(580)+10, Greenfoot.getRandomNumber(380)+10);
}
