Ok I am going to do it a different way.
What I would like is a shroom that spawns on certain random x coord.
I would like it to spawn levelwide, but not say between, x coords 50-100 AND NOT between xcoord 500-600.
How would I go by that?


1 2 3 | int x = getRandomNumber(getWidth()- 150 ); if (x > 50 ) x += 50 ; if (x > 500 ) x += 100 ; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | public void add( int addAmt) { ScoreCounter+=addAmt; updateImage(); int x = (Greenfoot.getRandomNumber(getWorld().getWidth()-( 1200 - 1088 )-( 352 - 282 )-( 896 - 640 ))); if (x > 1088 ) x += 112 ; if (x > 282 ) x += 70 ; if (x > 640 ) x += 256 ; int y = Greenfoot.getRandomNumber( 51 )+ 300 ; if (ScoreCounter == 1 ) { getWorld().addObject( new Shroom(), x, y); } if (ScoreCounter == 2 ) { getWorld().addObject( new Shroom(), x, y); } |
1 2 3 4 | int x = (Greenfoot.getRandomNumber(getWorld().getWidth()-( 352 - 282 )-( 896 - 640 )-( 1200 - 1088 ))); if (x > 282 ) x += 70 ; if (x > 640 ) x += 256 ; if (x > 1088 ) x += 112 ; |