hi, how can i make my actors continually appearing randomly at the same y axis?
import greenfoot.*; public class ahihihi extends World { egpuding egpuding = new egpuding(); jelatin jelatin = new jelatin(); prag prag = new prag(); /** * Constructor for objects of class anuto. * */ public ahihihi() { super(1100, 600, 1); prepare(); } public void act() { int randomNumber = Greenfoot.getRandomNumber(30); if(randomNumber == 15) { int randomX = Greenfoot.getRandomNumber(1100); int randomY = Greenfoot.getRandomNumber(600); addObject(egpuding, randomX, randomY); } if(randomNumber == 15) { int randomX = Greenfoot.getRandomNumber(1100); int randomY = Greenfoot.getRandomNumber(600); addObject(jelatin, randomX, randomY); } if(randomNumber == 15) { int randomX = Greenfoot.getRandomNumber(1100); int randomY = Greenfoot.getRandomNumber(600); addObject(prag, randomX, randomY); } }
public void eat () { Actor egpuding; egpuding = getOneObjectAtOffset(0, 0, egpuding.class); if (egpuding != null) { World world; world = getWorld(); ahihihi ahihihi = (ahihihi)world; counter counter = ahihihi.getcounter(); counter.addScore(); world.removeObject(egpuding); } Actor jelatin; jelatin = getOneObjectAtOffset(0, 0, jelatin.class); if (jelatin != null) { World world; world = getWorld(); ahihihi ahihihi = (ahihihi)world; counter counter = ahihihi.getcounter(); counter.addScore(); world.removeObject(jelatin); } Actor milkeu; milkeu = getOneObjectAtOffset(0, 0, milkeu.class); if (milkeu != null) { World world; world = getWorld(); ahihihi ahihihi = (ahihihi)world; counter counter = ahihihi.getcounter(); counter.addScore(); world.removeObject(milkeu); } }
public void eat () { Actor egpuding; egpuding = getOneObjectAtOffset(0, 0, egpuding.class); if (egpuding != null) { World world; world = getWorld(); ahihihi ahihihi = (ahihihi)world; counter counter = ahihihi.getcounter(); counter.addScore(); world.removeObject(egpuding); } Actor jelatin; jelatin = getOneObjectAtOffset(0, 0, jelatin.class); if (jelatin != null) { World world; world = getWorld(); ahihihi ahihihi = (ahihihi)world; counter counter = ahihihi.getcounter(); counter.addScore(); world.removeObject(jelatin); } Actor milkeu; milkeu = getOneObjectAtOffset(0, 0, milkeu.class); if (milkeu != null) { World world; world = getWorld(); ahihihi ahihihi = (ahihihi)world; counter counter = ahihihi.getcounter(); counter.addScore(); world.removeObject(milkeu); } }
if (getY() >= getWorld().getHeight()-1) setLocation(getX(), 0);