Exemplo n.º 1
0
        private void Move()
        {
            var hpos        = Head.Transform.Position.Round();
            var newPosition = Point.Lerp(
                hpos,
                new Point(hpos.X + movingDirectionX, hpos.Y + movingDirectionY),
                (Context.Time.SinceSceneStart - lastPositionChangeTime) * speed)
                              .Round();

            if (newPosition != hpos)
            {
                Head.Pixel = SnakeTile.BodyPixel;
                tail.Transform.Position = newPosition;
                Head.Next  = tail;
                Head       = tail;
                tail       = tail.Next;
                Head.Next  = null;
                Head.Pixel = SnakeTile.HeadPixel;

                lastPositionChangeTime = Context.Time.SinceSceneStart;
            }
        }