Created
June 9, 2015 10:11
-
-
Save Henry-E/148041a6f23026d01677 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// all this code needs to go in the loop which initialises the asteroids | |
bool isStillCheckingLocation = true; | |
while(isStillCheckingLocation) | |
{ | |
asteroidStartLocation = new Vector2 (UnityEngine.Random.Range (0, gameWidth), | |
UnityEngine.Random.Range (0, gameHeight)); | |
// we need to make sure the asteroids are not spawned too close to the player | |
if( (asteroidStartLocation.x < gameWidth * 0.4f || asteroidStartLocation.x > gameWidth * 0.6f) && | |
(asteroidStartLocation.y < gameHeight * 0.4f || asteroidStartLocation.y > gameHeight * 0.6f) ) | |
isStillCheckingLocation = false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment