Пример #1
0
 public void Collisions()
 {
     if ((testLine.DotFromPoint(AABB.BottomRight) < 0) && (AABB.Intersects(testLine)) )
     {
         while (testLine.DotFromPoint(AABB.BottomRight) < 0)
         {
             AABB.Move(new Vector2I(0, -1));
             velocity = Vector2I.Zero;
         }
     }
 }
Пример #2
0
 public static float Dot(Vector2I A, Vector2I B)
 {
     return (A.X * A.Y) + (B.X * B.Y);
 }
Пример #3
0
        public override void Update(GameTime gameTime)
        {
            mousePos = Input.GetMousePos(Matrix.Identity);

            dot = testLine.DotFromPoint(mousePos);

            int moveSpeed = 4;
            if (Input.IsKeyDown(Keys.A))
            {
                AABB.Move(new Vector2I(-1 * moveSpeed, 0));
            }
            if (Input.IsKeyDown(Keys.D))
            {
                AABB.Move(new Vector2I(1 * moveSpeed, 0));
            }
            if (Input.IsKeyDown(Keys.W))
            {
                AABB.Move(new Vector2I(0, -1 * moveSpeed));
            }
            if (Input.IsKeyDown(Keys.S))
            {
                AABB.Move(new Vector2I(0, 1 * moveSpeed));
            }
            if (Input.IsKeyPressed(Keys.Space))
            {
                velocity = new Vector2I(0, -20);
            }
            //Console.WriteLine(Input.GetLeftStick(PlayerIndex.One));
            velocity += gravity;
            AABB.Move(velocity);
            Collisions();
            //Vector2 start
            base.Update(gameTime);
        }