Time for action – displaying the flood
Add the following declarations to the
Game1
class:Private Const MaxWaterHeight As Integer = 244 Private Const WaterWidth As Integer = 297 Private waterOverlayStart As Vector2 = new Vector2(85, 245) Private waterPosition As Vector2 = new Vector2(478, 338)
Modify the
Draw()
method of theGame1
class by adding the following, right after theSpriteBatch.DrawString()
call that displays the player's score:Dim waterHeight As Integer waterHeight = CInt(MaxWaterHeight * (floodCount / 100)) spriteBatch.Draw(background, new Rectangle( CInt(waterPosition.X), CInt(waterPosition.Y + (MaxWaterHeight - waterHeight)), WaterWidth, waterHeight), new Rectangle( CInt(waterOverlayStart.X), CInt(waterOverlayStart.Y + (MaxWaterHeight - waterHeight)), WaterWidth, waterHeight), new Color(255, 255, 255, 180))
Try it out! You should now be able to watch the flood slowly increase in the flood tank. When...