I was able to spawn my enemies into the game (Thank you to the people that helped) but now only a few will spawn and then a massive horde of enemies will follow and I don't want that to happen.
Thank you in advance!
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Enemy here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Enemy extends Actor
{
/**
* Act - do whatever the Enemy wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
spawning();
setLocation(getX()-3, getY());
endgame();
if (getWorld() != null)despawn();
}
/**
* Spawns the enemy on the edge of the world randomly
*
*/
public void spawning()
{
if(Greenfoot.getRandomNumber(900) <= 11)
{
getWorld().addObject(new Enemy(),599,Greenfoot.getRandomNumber(400));
}
}
