Exemple #1
0
        public MainWindow()
        {
            InitializeComponent();
            m_holeLocation = new Point {
                X = Size / 2, Y = Size / 2, Height = 30
            };
            ((MainViewModel)DataContext).AddMeshHeights(m_sand);
            ((MainViewModel)DataContext).AddSphere(new Point3D(m_holeLocation.X + Radius, m_holeLocation.Y + Radius, m_holeLocation.Height), Radius);
            ((MainViewModel)DataContext).AddContainer(Size, Size, SandLevel);

            HelixPane.Camera.Position      = new Point3D(119.1, -187.8, 353.7);
            HelixPane.Camera.LookDirection = new Vector3D(3.4, 310.3, -346.2);

            if (X.IsAvailable)
            {
                m_gamepad = X.Gamepad_1;
                m_gamepad.StateChanged += ProcessXboxInput;
                X.StartPolling(m_gamepad);
            }

            Closing += (sender, args) =>
            {
                X.StopPolling();
                m_drawSync.RemoveParticipant();
                m_closed = true;
            };
        }
Exemple #2
0
        private bool Move(Point movement)
        {
            var newCenter = m_holeLocation + movement;

            newCenter.X      += Diameter / 2;
            newCenter.Y      += Diameter / 2;
            newCenter.Height -= (Diameter / 2) + 2;

            if (newCenter.X < 0 || newCenter.X >= Size || newCenter.Y < 0 || newCenter.Y >= Size || newCenter.Height < 0 || newCenter.Height > 100)
            {
                return(false);
            }
            else
            {
                var newPosition = m_holeLocation + movement;
                m_holeLocation.X      = newPosition.X;
                m_holeLocation.Y      = newPosition.Y;
                m_holeLocation.Height = newPosition.Height;
                ApplyBallAndDisplaySand();
                return(true);
            }
        }
Exemple #3
0
        private void ProcessXboxDpadPress(object sender, EventArgs e)
        {
            Point yolo = null;

            if (IsPressed(X.Gamepad.GamepadButtons.Dpad_Up))
            {
                yolo = new Point {
                    Y = 1
                };
            }
            else if (IsPressed(X.Gamepad.GamepadButtons.Dpad_Down))
            {
                yolo = new Point {
                    Y = -1
                };
            }
            else if (IsPressed(X.Gamepad.GamepadButtons.Dpad_Left))
            {
                yolo = new Point {
                    X = -1
                };
            }
            else if (IsPressed(X.Gamepad.GamepadButtons.Dpad_Right))
            {
                yolo = new Point {
                    X = 1
                };
            }

            if (yolo != null)
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    Move(yolo);
                }));
            }
        }