This site requires JavaScript, please enable it in your browser!
Greenfoot back
LittleJacob
LittleJacob wrote ...

2013/5/12

Shooting randomly

LittleJacob LittleJacob

2013/5/12

#
i want to let my aliens shoot randomly. i have looked up a lot of codes, but i can't find any that works for me. In my code i tried to let the aliens shoot with a key but even that doesn't work. I would be really thankful if someone could make the aliens shoot randomly.
JetLennit JetLennit

2013/5/12

#
So, you want code to make aliens to shoot randomly? If so, what is the name of the bullet class
LittleJacob LittleJacob

2013/5/12

#
kogel
JetLennit JetLennit

2013/5/12

#
So, this is the code
if(Greenfoot.getRandomNumber(500) < 5)
{
     kogel kogel = new kogel()
     getWorld().addObject(kogel, getX(), getY())
}
Put this in the act() method. I think this is what you want
LittleJacob LittleJacob

2013/5/12

#
Thnks
You need to login to post a reply.