Esempio n. 1
0
        public override void OnUpdate()
        {
            if (player == null)
            {
                return;
            }
            if (up)
            {
                player.Position.Y -= 1f;
            }
            if (down)
            {
                player.Position.Y += 1f;
            }
            if (left)
            {
                player.Position.X -= 1f;
            }
            if (right)
            {
                player.Position.X += 1f;
            }
            //if(player.IsColliding(player, player2))
            //{
            //    Log.Info("COLLIDING with player");
            //}
            Sprite2D coin = player.IsColliding("Coin");

            if (coin != null)
            {
                coin.DestroySelf();
            }
            if (player.IsColliding("Ground") != null)
            {
                player.Position.X = lastPos.X;
                player.Position.Y = lastPos.Y;
            }
            else
            {
                lastPos.X = player.Position.X;
                lastPos.Y = player.Position.Y;
            }
        }
Esempio n. 2
0
 //onUpdate is called once per frame.
 public override void OnUpdate()
 {
     time++;
     if (player != null)
     {
         if (up)
         {
             player.Position.y -= speed;
         }
         if (down)
         {
             player.Position.y += speed;
         }
         if (left)
         {
             player.Position.x -= speed;
         }
         if (right)
         {
             player.Position.x += speed;
         }
         if (player.IsColliding("Ground") != null)
         {
             player.Position.x = lastPos.x;
             player.Position.y = lastPos.y;
         }
         Sprite2D jewel = player.IsColliding("Jewel");
         if (jewel != null)
         {
             jewel.DestroySelf();
         }
         Sprite2D coin = player.IsColliding("Coin");
         if (coin != null)
         {
             coin.DestroySelf();
         }
         else
         {
             lastPos.x = player.Position.x;
             lastPos.y = player.Position.y;
         }
     }
 }
        public override void OnUpdate()
        {
            if (player == null)
            {
                return;
            }
            if (up)
            {
                player.Position.Y -= 1f;
            }
            if (down)
            {
                player.Position.Y += 1f;
            }
            if (left)
            {
                player.Position.X -= 1f;
            }
            if (right)
            {
                player.Position.X += 1f;
            }
            Sprite2D coin = player.IsColliding("Coin");

            if (coin != null)
            {
                coin.DestroySelf();
            }
            if (player.IsColliding("Ground") != null)
            {
                //times++;
                //Log.Info($"Colliding {times}");
                player.Position = lastPos.Copy();
            }
            else
            {
                lastPos = player.Position.Copy();
            }
        }