Hi all,
Basically I have this trip wire in my game and I would like at the start of every time the game starts that it spawns 2 trip wires in random set locations. But i'm not sure how I could do it, any advice?
addObject( new Trip_Wire, 125, 380 );
if (Greenfoot.getRandomNumber(2)==0) addObject(new Trip_Wire(), 125, 380); else addObject(new Trip_Wire(), 885, 381);
private int[] locX = {125, 885},
locY = {885, 381};
//…
int r = Greenfoot.getRandomNumber(locX.length);
addObject(new Trip_Wire(), locX[r], locY[r]);private int[][] loc =
{
{125, 380},
{885, 381}
};
//…
int r = Greenfoot.getRandomNumber(loc.length);
addObject(new Trip_Wire(), loc[r][0], loc[r][1]); {
private int[][] loc =
{
{125, 380},
{885, 381}
};
int r = Greenfoot.getRandomNumber(loc.length);
addObject(new Trip_Wire(), loc[r][0], loc[r][1]);
}