Ejemplo n.º 1
0
        public virtual void Draw(Vector2 _mousePos)
        {
            int state = 0;

            if (rect.ColVector(_mousePos))
            {
                state = 1;

                if (Input.mbLeft.down)
                {
                    state = 2;
                }
            }

            rect.Draw(state == 0 ? backColor : state == 1 ? Color.Gray : Color.White);
        }
Ejemplo n.º 2
0
        public void UpdateEnd(int resX, int resY)
        {
            //Vector3 move = Vector3.Zero;
            //if (Input.a.down)
            //    move.X++;
            //if (Input.d.down)
            //    move.X--;
            //if (Input.w.down)
            //    move.Z++;
            //if (Input.s.down)
            //    move.Z--;
            //if (Input.space.down)
            //    move.Y++;
            //if (Input.leftShift.down)
            //    move.Y--;

            //if (move != Vector3.Zero)
            //{
            //    move.Normalize();
            //    move *= moveSpeed;

            //    if (Input.leftControl.down)
            //        move /= 10f;
            //    Vector2 moveXZ = new Vector2(move.X, move.Z);
            //    moveXZ = Vector2.Transform(moveXZ, Matrix.CreateRotationZ(yaw));
            //    move = new Vector3(moveXZ.X, move.Y, moveXZ.Y);
            //    pos += move;
            //}

            //view *= Matrix.CreateRotationY(0.01f);
            //Vector2 mbPos = Mouse.GetState().Position.ToVector2();

            //if (mbPos != Input.mbPos)
            //{
            //    Console.WriteLine("y");
            //}

            Vector2 mouseMove = Input.mbPos - mbPosPast;// new Vector2(resX, resY) / 2f;

            mouseMove *= mouseSensitivity;
            //view *= Matrix.CreateFromYawPitchRoll(mouseMove.X, mouseMove.Y, 0);

            //pos += new Vector3(mouseMove.X, 0, mouseMove.Y);

            mouseMoveSave += (mouseMove - mouseMoveSave) * 0.5f;

            yaw   += mouseMoveSave.X;
            pitch += mouseMoveSave.Y;

            if (Math.Abs(pitch) > MathHelper.PiOver2 - 0.1f)
            {
                pitch = Math.Sign(pitch) * (MathHelper.PiOver2 - 0.1f);
            }

            mbPosPast = Input.mbPos;

            if (mouseMove != Vector2.Zero)
            {
                int         border = 10;
                M_Rectangle rect   = new M_Rectangle(border, border, resX - border * 2, resY - border * 2);
                if (!rect.ColVector(Input.mbPos))
                {
                    CenterMouse();
                }
                //Console.WriteLine("x");
            }
            else
            {
            }  //Console.WriteLine("m");

            UpdateView();
        }