This code is slowing my game down because it is so big... is there an easier way to code this?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | public void spawnTank() { firstRand = (Greenfoot.getRandomNumber( 600 )); secondRand = (Greenfoot.getRandomNumber( 4 )); northAndSouth = (Greenfoot.getRandomNumber( 640 )); eastAndWest = (Greenfoot.getRandomNumber( 540 )); tank tank = new tank(); if (firstRand == 0 ) { if (secondRand == 0 ) { //spawn west addObject(tank, 5 , northAndSouth + 5 ); } if (secondRand == 1 ) { //spawn south addObject(tank, northAndSouth + 5 , 645 ); } if (secondRand == 2 ) { //spawn east addObject(tank, 645 , northAndSouth + 5 ); } if (secondRand == 3 ) { //spawn west addObject(tank, northAndSouth + 5 , 5 ); } } } |