コード例 #1
0
        public override void HandleCollision(GameObjects p)
        {
            if (speed.X > 0 && Hitbox().Right > p.Hitbox().Left&& Hitbox().Center.Y > p.Hitbox().Top&& Hitbox().Center.X < p.Hitbox().Right)   //Högerkollision
            {
                speed.X = -1;
            }
            else if (Hitbox().Left < p.Hitbox().Right&& Hitbox().Center.Y > p.Hitbox().Top)  //Vänsterkollision
            {
                speed.X = 1;

                speed.Y = 1;
            }



            else
            {
                isOnGround = true;
                speed.Y    = 0;
                base.HandleCollision(p);
            }
        }
コード例 #2
0
 public virtual void HandleCollision(GameObjects other)
 {
     hitBox.Y = other.hitBox.Y - hitBox.Height + 1;
     pos.Y    = hitBox.Y;
 }
コード例 #3
0
 public virtual bool isColliding(GameObjects p)
 {
     return(hitBox.Intersects(p.hitBox));
 }