public override void Update(GameTime gametime) { base.Update(gametime); if (InputManager.Instance.KeyDown(Keys.Left) && _position.X > 4) { //YARRR code were changed here! Vector2 temp = _position; temp.X -= 5; _position = temp; } else if (InputManager.Instance.KeyDown(Keys.Right) && _position.X < ScreenManager.Instance.Dimensions.X - _image.SourceRect.Width) { Vector2 temp = _position; temp.X += 5; _position = temp; } else if (InputManager.Instance.KeyDown(Keys.Up) && _position.Y > 4) { Vector2 temp = _position; temp.Y -= 5; _position = temp; } else if (InputManager.Instance.KeyDown(Keys.Down) && _position.Y < ScreenManager.Instance.Dimensions.Y - _image.SourceRect.Height) { Vector2 temp = _position; temp.Y += 5; _position = temp; } else if (InputManager.Instance.LeftMouseDown() || InputManager.Instance.LeftMouseClick()) { if (delay % 20 == 0) { _projectiles.Add(ProjectileFactory.Shoot(_position, damageModifier, ammo, true)); delay = 0; } delay++; } foreach (Projectile l in _projectiles) { if (l.IsActive) { l.Update(gametime); } } _image.Position = _position; _image.Update(gametime); }
public override void Update(GameTime gametime) { base.Update(gametime); delay++; if (InputManager.Instance.LeftMouseDown() || InputManager.Instance.LeftMouseClick()) { if (delay > 20) { ProjectileFactory.Shoot(_position, damageModifier, _ammo, true); delay = 0; } } Image.Position = _position; Image.Rotation = (float)Math.Atan2(_position.Y - InputManager.Instance.MousePosition.Y, _position.X - InputManager.Instance.MousePosition.X); _stand.Update(gametime); }