Hi, I require some assistance please.
I am attempting to return a RNG x and y value for a set of coordinates.
The x and y i am returning is within a set area minus an area inside of the set area. I am adding an object within the set area in my world.
I am getting issues with the add object part and when i try to retrieve the returned x and y from coordinates()
I have attempted multiple variations of the code but must be missing something, im not too adept at Java yet.
I appreciate any help and open to any scrutiny. Its all a learning experience :)
Thanks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | public int coordinates() { int xInside = Greenfoot.getRandomNumber( 600 )+ 130 ; int yInside = Greenfoot.getRandomNumber( 605 )+ 115 ; int xOutside = Greenfoot.getRandomNumber( 430 )+ 225 ; int yOutside = Greenfoot.getRandomNumber( 400 )+ 210 ; if (((xInside >= 130 && xInside <= 600 ) && ( yInside >= 115 && yInside <= 605 )) && ((xOutside >= 225 && xOutside <= 430 ) && (yOutside >= 210 && yOutside <= 400 ))) { return xInside; return yInside; } } public void zoneRNG() { barrels1[] numBarrels = new barrels1[ 3 ]; for ( int i= 0 ; i<numBarrels.length;i++) { numBarrels[i] = new barrels1(); addObject(numBarrels[i], coordinates( "xInside" , "yInside" )); } } |