Guest User

Untitled

a guest
Oct 15th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private function physicsHandler(e:Event):void
  2.         {
  3.             for (var u:int = 0; u < physObjects.length; u++)
  4.             {
  5.                 if(u != 0 && physObjects[u].movable)
  6.                 {
  7.                 physObjects[u].y +=  physObjects[u].yVelocity;
  8.                 physObjects[u].x +=  physObjects[u].xVelocity;
  9.                 physObjects[u].yVelocity /=  1.2;
  10.                 physObjects[u].xVelocity /=  1.2;
  11.                 if (physObjects[u].onGround == false && physObjects[u].gravity < 10 && physObjects[u].gravity > -10)
  12.                 {
  13.                     physObjects[u].gravity +=  gravPower;
  14.                 }
  15.                 if (physObjects[u].onGround)
  16.                 {
  17.                     physObjects[u].gravity = 0;
  18.                     physObjects[u].yVelocity = 0;
  19.                 }
  20.                 physObjects[u].y +=  physObjects[u].gravity;
  21.                 }
  22.             }
  23.             this.y +=  this.yVelocity;
  24.             this.x +=  this.xVelocity;
  25.             this.yVelocity /=  1.2;
  26.             this.xVelocity /=  1.2;
  27.             if (this.onGround == false && this.gravity < 10 && this.gravity > -10)
  28.             {
  29.                 this.gravity +=  gravPower;
  30.             }
  31.             if (this.onGround)
  32.             {
  33.                 this.gravity = 0;
  34.                 this.yVelocity = 0;
  35.             }
  36.             this.y -=  this.gravity;
  37.             Body.Update();
  38.  
  39.             for (var i:int = physObjects.length - 1; i >= 0; i--)
  40.             {
  41.                 for (var n:int = 0; n < physObjects.length; n++)
  42.                 {
  43.                    
  44.                     //trace(physObjects[0].bod.currentBoundsX[1],physObjects[1].bod.currentBoundsX[0]);
  45.                     //trace(physObjects[0].bod.currentBoundsX[1] - physObjects[0].bod.currentBoundsX[0],physObjects[1].bod.currentBoundsX[1] - physObjects[1].bod.currentBoundsX[0]);
  46.                     //trace(physObjects[1].bod.currentBoundsY[0],physObjects[1].bod.currentBoundsY[1]);
  47.                     if(physObjects[i].bod.currentBoundsY[0] >= physObjects[n].bod.currentBoundsY[1] && physObjects[i].bod.currentBoundsY[1] <= physObjects[n].bod.currentBoundsY[0] && physObjects[i].bod.currentBoundsX[0] >= physObjects[n].bod.currentBoundsX[0] && physObjects[i].bod.currentBoundsX[1] <= physObjects[n].bod.currentBoundsX[1])
  48.                     {
  49.                     physObjects[i].onGround = true
  50.                     trace(testNum);
  51.                     testNum++;
  52.                     }
  53.                     else
  54.                     {
  55.                     physObjects[i].onGround = false;
  56.                     }
  57.  
  58.                     if(physObjects[0].bod.currentBoundsY[0] >= physObjects[1].bod.currentBoundsY[1] && physObjects[0].bod.currentBoundsY[1] <= physObjects[1].bod.currentBoundsY[0] && physObjects[0].bod.currentBoundsX[0] >= physObjects[1].bod.currentBoundsX[0] && physObjects[0].bod.currentBoundsX[1] <= physObjects[1].bod.currentBoundsX[1])
  59.                     {
  60.                     this.onGround = true
  61.                     trace(testNum);
  62.                     testNum++;
  63.                     }
  64.                     else
  65.                     {
  66.                     this.onGround = false;
  67.                     }
  68.                 }
  69.             }
  70.         }
Add Comment
Please, Sign In to add comment