Guest User

Untitled

a guest
Aug 21st, 2018
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //physx
  2. this.mass = 1500
  3. var Fx1:Number = 0
  4. var Fy1:Number = 0
  5. var Fr1:Number = 0
  6. var Fx2:Number = 0
  7. var Fy2:Number = 0
  8. var Fr2:Number = 0
  9. var ax1:Number = 0
  10. var ax2:Number = 0
  11. var ay1:Number = 0
  12. var ay2:Number = 0
  13. var r1:Number
  14. var r2:Number
  15. var G:Number = 100
  16.  
  17. var xspeed:Number = 0
  18. var yspeed:Number = 0
  19. var gravity:Number = 0.2
  20. var collision:Boolean = false
  21. var right:Boolean = false
  22. var left:Boolean = false
  23. var walkspeed:Number = 3
  24. var jumpvelo:Number = 7
  25. var tcolliding:Boolean = false
  26. var startx:Number = player_start_mc._x
  27. var starty:Number = player_start_mc._y
  28. var bid:Number = 0
  29. var focuslevel:Number
  30. var focuslevelp:Number
  31. var savefile = SharedObject.getLocal("aitd_saves");
  32. var timerMain:Number
  33. var fps = 60
  34. timerMain = setInterval( this, "Main", 1000/fps)
  35. Main = function ()
  36. {
  37.     focuslevelp = focuslevel+1
  38.     startx = _root.player_start_mc._x
  39.     starty = _root.player_start_mc._y
  40.     yspeed+= gravity
  41.     if(_root.hit1_mc.hitTest(this._x, this._y+10, true))
  42.     {
  43.         yspeed = 0
  44.         collision = true
  45.         if(!_root.hit1_mc.hitTest(this._x, this._y, true))
  46.         {
  47.             while(collision)
  48.             {
  49.                 this._y --
  50.                 if(_root.hit1_mc.hitTest(this._x, this._y+10, true))
  51.                 {
  52.                     collision = true
  53.                 } else {collision = false}
  54.             }
  55.         }
  56.     }
  57.     if(!_root.hit1_mc.hitTest(this._x, this._y, true))
  58.     {
  59.         this._y ++
  60.     }
  61.    
  62.  
  63.     if(Key.isDown(Key.LEFT) &&! Key.isDown(Key.RIGHT))
  64.     {
  65.         if(!_root.hit1_mc.hitTest(this._x-10, this._y, true))
  66.         {
  67.             left = true
  68.         }
  69.     } else {left = false}
  70.     if(Key.isDown(Key.RIGHT) &&! Key.isDown(Key.LEFT))
  71.     {
  72.         if(!_root.hit1_mc.hitTest(this._x+10, this._y, true))
  73.         {
  74.             right = true
  75.         }
  76.     } else {right = false}
  77.     if(!Key.isDown(Key.LEFT) && !Key.isDown(Key.RIGHT))
  78.     {
  79.         xspeed *= 0.9
  80.     }
  81.     if(left)
  82.     {
  83.         xspeed = walkspeed *-1
  84.     }
  85.     if(right)
  86.     {
  87.         xspeed = walkspeed
  88.     }
  89.     if(left && right)
  90.     {
  91.         xspeed *= 0.9
  92.     }
  93.     if(_root.hit1_mc.hitTest(this._x-10, this._y, true))
  94.     {
  95.         this._x += walkspeed
  96.         if(xspeed<walkspeed*-1)
  97.         {
  98.             xspeed *= -1
  99.         } else {
  100.             xspeed = 0
  101.         }
  102.     }
  103.     if(_root.hit1_mc.hitTest(this._x+10, this._y, true))
  104.     {
  105.         this._x -= walkspeed
  106.         if(xspeed>walkspeed)
  107.         {
  108.             xspeed *= -1
  109.         } else {
  110.             xspeed = 0
  111.         }
  112.     }
  113.     if(Key.isDown(83))
  114.     {
  115.         if(_root.hit1_mc.hitTest(this._x, this._y+10, true))
  116.         {
  117.             yspeed = jumpvelo * -1
  118.         }
  119.     }
  120.     if(_root.hit1_mc.hitTest(this._x, this._y-10, true))
  121.     {
  122.         tcolliding = true
  123.         while(tcolliding)
  124.         {
  125.             if(_root.hit1_mc.hitTest(this._x, this._y-10, true))
  126.             {
  127.                 tcolliding = true
  128.             } else {tcolliding = false}
  129.             this._y++
  130.         }
  131.         if(Key.isDown(68))
  132.         {
  133.             yspeed *= -1
  134.         } else {
  135.             yspeed = 0
  136.         }
  137.        
  138.     }
  139.     if(Key.isDown(68))
  140.     {
  141.         if(yspeed>0)
  142.         {
  143.             if(_root.hit1_mc.hitTest(this._x, this._y+20, true))
  144.             {
  145.                 yspeed *= -1.1
  146.             }
  147.         }
  148.     }
  149.     if(_root.hit1_mc.hitTest(this._x-12, this._y, true))
  150.     {
  151.         if(Key.isDown(82))
  152.         {
  153.             xspeed = yspeed*-2
  154.         }
  155.     }
  156.     if(Key.isDown(1))
  157.     {
  158.         bid++
  159.         _root.hit1_mc.attachMovie("block_mc", "block_mc"+bid, _root.hit1_mc.getNextHighestDepth())
  160.         _root.hit1_mc["block_mc"+bid]._x = _root._xmouse-_root.hit1_mc._x
  161.         _root.hit1_mc["block_mc"+bid]._y = _root._ymouse-_root.hit1_mc._y
  162.     }
  163.     this._y += yspeed
  164.     this._x += xspeed
  165.     if(Key.isDown(82))
  166.     {
  167.         this._x = startx
  168.         this._y = starty
  169.         xspeed = 0
  170.         yspeed = 0
  171.         _root.hit1_mc.destroy = true
  172.     } else {
  173.         _root.hit1_mc.destroy = false
  174.     }
  175.     if(_root["door"+focuslevel+"_mc"].hitTest(this._x, this._y, false))
  176.     {
  177.         _root.gotoAndStop(focuslevel+1)
  178.         this._x = startx
  179.         this._y = starty
  180.         xspeed = 0
  181.         yspeed = 0
  182.         _root.hit1_mc.destroy = true
  183.     }
  184.     //cheat
  185.     if(Key.isDown(76))
  186.     {
  187.         if(Key.isDown(48))
  188.         {
  189.             _root.gotoAndPlay(0)
  190.         }
  191.         if(Key.isDown(49))
  192.         {
  193.             _root.gotoAndStop(1)
  194.         }
  195.         if(Key.isDown(50))
  196.         {
  197.             _root.gotoAndStop(2)
  198.         }
  199.         if(Key.isDown(51))
  200.         {
  201.             _root.gotoAndStop(3)
  202.         }
  203.         if(Key.isDown(52))
  204.         {
  205.             _root.gotoAndStop(4)
  206.         }
  207.         if(Key.isDown(53))
  208.         {
  209.             _root.gotoAndStop(5)
  210.         }
  211.         if(Key.isDown(54))
  212.         {
  213.             _root.gotoAndStop(6)
  214.         }
  215.         if(Key.isDown(55))
  216.         {
  217.             _root.gotoAndStop(7)
  218.         }
  219.         if(Key.isDown(56))
  220.         {
  221.             _root.gotoAndStop(8)
  222.         }
  223.         if(Key.isDown(57))
  224.         {
  225.             _root.gotoAndStop(9)
  226.         }
  227.     }
  228.     if(Key.isDown(65))
  229.     {
  230.         savefile.data.focuslevel=this.focuslevel;
  231.         savefile.flush();
  232.     }
  233.     if(Key.isDown(66))
  234.     {
  235.         _root.gotoAndStop(savefile.data.focuslevel)
  236.     }
  237.     //Black Holes
  238.     //Fz = (G*m1*m2)/(r^2)
  239.     r1 = Math.sqrt(((_root.bhole1_mc._x-this._x)*(_root.bhole1_mc._x-this._x))+((this._y-_root.bhole1_mc._y)*(this._y-_root.bhole1_mc._y)))
  240.     Fr1 = (G*this.mass*_root.bhole1_mc.mass)/(r1)
  241.     Fx1 = (Fr1/r1)*(_root.bhole1_mc._x-this._x)
  242.     Fy1 = (Fr1/r1)*(_root.bhole1_mc._y-this._y)
  243.     ax1 = Fx1/this.mass
  244.     ay1 = Fy1/this.mass
  245.     this._x += ax1
  246.     this._y += ay1
  247.     trace(Fx1 + ", " + Fy1)
  248.     stage.showDefaultContextMenu = false;
  249.     Stage.showMenu=false
  250.    
  251. }
Add Comment
Please, Sign In to add comment