public override void Update(GameTime gameTime, Rectangle viewportRect) { Vector2 difference; //difference between positions difference.X = Gerald.getPos().X - screenPos.X; difference.Y = Gerald.getPos().Y - screenPos.Y; // Get the direction that the shark needs to go in. difference.Normalize(); // Move the chum screenPos = screenPos + Velocity * difference * (float)gameTime.ElapsedGameTime.TotalSeconds; }
public override void Update(GameTime gameTime, Rectangle viewportRect) { Vector2 difference; //difference between positions difference.X = food.getPos().X - screenPos.X; difference.Y = food.getPos().X - screenPos.Y; // Get the direction that the shark needs to go in. difference.Normalize(); // Move the shark screenPos = screenPos + Velocity * difference * (float)gameTime.ElapsedGameTime.TotalSeconds; firetime += (float)gameTime.ElapsedGameTime.Milliseconds / 1000; if (firetime >= weapon.getFireSpeed()) { firedBullets.Add(weapon.FireProjectile(screenPos)); firetime = 0.0f; } }