Time for action – positioning the asteroids
Add methods to generate random locations and velocities to the
AsteroidManager
class:Private Function randomLocation() As Vector2 Dim location As Vector2 = Vector2.Zero Dim locationOK As Boolean = True Dim tryCount As Integer = 0 Do locationOK = True Select Case (rand.Next(0,3)) Case 0 location.X = -initialFrame.Width location.Y = rand.Next(0, screenHeight) Case 1 location.X = screenWidth location.Y = rand.Next(0, screenHeight) Case 2 location.X = rand.Next(0, screenWidth) location.Y = -initialFrame.Height End Select For Each asteroid As Sprite in Asteroids If (asteroid.IsBoxColliding( New Rectangle( CInt(location.X), CInt(location.Y), initialFrame.Width, ...