Time for action – updating and drawing Asteroids
Add the
Update()
andDraw()
methods to theAsteroidManager
class:Public Sub Update(gameTime As GameTime) For Each asteroid As Sprite In Asteroids asteroid.Update(gameTime) If Not isOnScreen(asteroid) Then asteroid.Location = randomLocation() asteroid.Velocity = randomVelocity() End If Next End Sub Public Sub Draw(spriteBatch As SpriteBatch) For Each asteroid As Sprite In Asteroids asteroid.Draw(spriteBatch) Next End Sub
Add a declaration for the
AsteroidManager
in the declarations section of theGame1
class:Private _asteroidManager As AsteroidManager
In the
Game1
class'LoadContent()
method, initialize_asteroidManager
, after the initialization of the_starField
object:_asteroidManager = New AsteroidManager( 10, spriteSheet, new Rectangle(0, 0, 50, 50), 20, Me.Window.ClientBounds.Width Me.Window.ClientBounds.Height)
Add the following line to Game1...