Example #1
0
        private void DestroyRaycast(float length)
        {
            var     m          = Mouse.GetState();
            Vector3 startPoint = Position;
            Vector3 endPoint   = Position + (Direction * length);

            for (int i = 0; i < length * 4; i++)
            {
                Vector3 current = Vector3.Lerp(startPoint, endPoint, (i / 4f) / (length));

                // Check collision
                if (ChunkManager.CheckCollision(current) && m.LeftButton == ButtonState.Pressed && pressed == false)
                {
                    Renderer.AddDebugLine(new DebugLine(startPoint, current, Color.Red));

                    ChunkManager.RemoveBlock(current);

                    pressed = true;
                    return;
                }
                else if (m.LeftButton == ButtonState.Released && pressed == true)
                {
                    pressed = false;
                }
            }
        }