Hello, for a school project we are making a game. Its a duck hunt twist.
The game is still in progress.. Anyways, we are facing a problem.
We want to have a Goat spawn at the left bottom corner of the screen, that walks to the right corner of the screen and then dissapears. It will only make goat sounds and look funny, further has this actor no actual part of the game.
We tried creating a for loop with a random number for spawning it. The problem is that once it has spawned and done what its suposed to do, it never respawns again...
First we tried this code thinking that this method will be re-executed multiple times when having the game "run".. but it doesn't.
Then we tried with a for loop, giving the condition a very high number so it will repeat itself more often but in that case it overloads the CPU making the game run with insane lag.
Can anyone help out please :)
public void randomGoat() { int goat = Greenfoot.getRandomNumber(20); if (goat <= 5) { addObject(new Goat(), 51, 553); } }