コード例 #1
0
        public override void Update(GameTime gameTime, Rectangle viewportRect)
        {
            Vector2 difference;

            //difference between positions
            difference.X = food.getPos().X - screenPos.X;
            difference.Y = food.getPos().Y - 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;
        }