Time for action – updating and drawing the player's ship
Add the
imposeMovementLimits()
helper method to the PlayerManager class:private void imposeMovementLimits() { Vector2 location = playerSprite.Location; if (location.X < playerAreaLimit.X) location.X = playerAreaLimit.X; if (location.X > (playerAreaLimit.Right - playerSprite.Source.Width)) location.X = (playerAreaLimit.Right - playerSprite.Source.Width); if (location.Y < playerAreaLimit.Y) location.Y = playerAreaLimit.Y; if (location.Y > (playerAreaLimit.Bottom - playerSprite.Source.Height)) location.Y = (playerAreaLimit.Bottom - playerSprite.Source.Height); playerSprite.Location = location; }
Add the
Update()
method to the PlayerManager class:public void Update(GameTime gameTime) { PlayerShotManager.Update(gameTime); if (!Destroyed) { playerSprite.Velocity = Vector2.Zero; shotTimer += (float...