Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //physx
- this.mass = 1500
- var Fx1:Number = 0
- var Fy1:Number = 0
- var Fr1:Number = 0
- var Fx2:Number = 0
- var Fy2:Number = 0
- var Fr2:Number = 0
- var ax1:Number = 0
- var ax2:Number = 0
- var ay1:Number = 0
- var ay2:Number = 0
- var r1:Number
- var r2:Number
- var G:Number = 100
- var xspeed:Number = 0
- var yspeed:Number = 0
- var gravity:Number = 0.2
- var collision:Boolean = false
- var right:Boolean = false
- var left:Boolean = false
- var walkspeed:Number = 3
- var jumpvelo:Number = 7
- var tcolliding:Boolean = false
- var startx:Number = player_start_mc._x
- var starty:Number = player_start_mc._y
- var bid:Number = 0
- var focuslevel:Number
- var focuslevelp:Number
- var savefile = SharedObject.getLocal("aitd_saves");
- var timerMain:Number
- var fps = 60
- timerMain = setInterval( this, "Main", 1000/fps)
- Main = function ()
- {
- focuslevelp = focuslevel+1
- startx = _root.player_start_mc._x
- starty = _root.player_start_mc._y
- yspeed+= gravity
- if(_root.hit1_mc.hitTest(this._x, this._y+10, true))
- {
- yspeed = 0
- collision = true
- if(!_root.hit1_mc.hitTest(this._x, this._y, true))
- {
- while(collision)
- {
- this._y --
- if(_root.hit1_mc.hitTest(this._x, this._y+10, true))
- {
- collision = true
- } else {collision = false}
- }
- }
- }
- if(!_root.hit1_mc.hitTest(this._x, this._y, true))
- {
- this._y ++
- }
- if(Key.isDown(Key.LEFT) &&! Key.isDown(Key.RIGHT))
- {
- if(!_root.hit1_mc.hitTest(this._x-10, this._y, true))
- {
- left = true
- }
- } else {left = false}
- if(Key.isDown(Key.RIGHT) &&! Key.isDown(Key.LEFT))
- {
- if(!_root.hit1_mc.hitTest(this._x+10, this._y, true))
- {
- right = true
- }
- } else {right = false}
- if(!Key.isDown(Key.LEFT) && !Key.isDown(Key.RIGHT))
- {
- xspeed *= 0.9
- }
- if(left)
- {
- xspeed = walkspeed *-1
- }
- if(right)
- {
- xspeed = walkspeed
- }
- if(left && right)
- {
- xspeed *= 0.9
- }
- if(_root.hit1_mc.hitTest(this._x-10, this._y, true))
- {
- this._x += walkspeed
- if(xspeed<walkspeed*-1)
- {
- xspeed *= -1
- } else {
- xspeed = 0
- }
- }
- if(_root.hit1_mc.hitTest(this._x+10, this._y, true))
- {
- this._x -= walkspeed
- if(xspeed>walkspeed)
- {
- xspeed *= -1
- } else {
- xspeed = 0
- }
- }
- if(Key.isDown(83))
- {
- if(_root.hit1_mc.hitTest(this._x, this._y+10, true))
- {
- yspeed = jumpvelo * -1
- }
- }
- if(_root.hit1_mc.hitTest(this._x, this._y-10, true))
- {
- tcolliding = true
- while(tcolliding)
- {
- if(_root.hit1_mc.hitTest(this._x, this._y-10, true))
- {
- tcolliding = true
- } else {tcolliding = false}
- this._y++
- }
- if(Key.isDown(68))
- {
- yspeed *= -1
- } else {
- yspeed = 0
- }
- }
- if(Key.isDown(68))
- {
- if(yspeed>0)
- {
- if(_root.hit1_mc.hitTest(this._x, this._y+20, true))
- {
- yspeed *= -1.1
- }
- }
- }
- if(_root.hit1_mc.hitTest(this._x-12, this._y, true))
- {
- if(Key.isDown(82))
- {
- xspeed = yspeed*-2
- }
- }
- if(Key.isDown(1))
- {
- bid++
- _root.hit1_mc.attachMovie("block_mc", "block_mc"+bid, _root.hit1_mc.getNextHighestDepth())
- _root.hit1_mc["block_mc"+bid]._x = _root._xmouse-_root.hit1_mc._x
- _root.hit1_mc["block_mc"+bid]._y = _root._ymouse-_root.hit1_mc._y
- }
- this._y += yspeed
- this._x += xspeed
- if(Key.isDown(82))
- {
- this._x = startx
- this._y = starty
- xspeed = 0
- yspeed = 0
- _root.hit1_mc.destroy = true
- } else {
- _root.hit1_mc.destroy = false
- }
- if(_root["door"+focuslevel+"_mc"].hitTest(this._x, this._y, false))
- {
- _root.gotoAndStop(focuslevel+1)
- this._x = startx
- this._y = starty
- xspeed = 0
- yspeed = 0
- _root.hit1_mc.destroy = true
- }
- //cheat
- if(Key.isDown(76))
- {
- if(Key.isDown(48))
- {
- _root.gotoAndPlay(0)
- }
- if(Key.isDown(49))
- {
- _root.gotoAndStop(1)
- }
- if(Key.isDown(50))
- {
- _root.gotoAndStop(2)
- }
- if(Key.isDown(51))
- {
- _root.gotoAndStop(3)
- }
- if(Key.isDown(52))
- {
- _root.gotoAndStop(4)
- }
- if(Key.isDown(53))
- {
- _root.gotoAndStop(5)
- }
- if(Key.isDown(54))
- {
- _root.gotoAndStop(6)
- }
- if(Key.isDown(55))
- {
- _root.gotoAndStop(7)
- }
- if(Key.isDown(56))
- {
- _root.gotoAndStop(8)
- }
- if(Key.isDown(57))
- {
- _root.gotoAndStop(9)
- }
- }
- if(Key.isDown(65))
- {
- savefile.data.focuslevel=this.focuslevel;
- savefile.flush();
- }
- if(Key.isDown(66))
- {
- _root.gotoAndStop(savefile.data.focuslevel)
- }
- //Black Holes
- //Fz = (G*m1*m2)/(r^2)
- 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)))
- Fr1 = (G*this.mass*_root.bhole1_mc.mass)/(r1)
- Fx1 = (Fr1/r1)*(_root.bhole1_mc._x-this._x)
- Fy1 = (Fr1/r1)*(_root.bhole1_mc._y-this._y)
- ax1 = Fx1/this.mass
- ay1 = Fy1/this.mass
- this._x += ax1
- this._y += ay1
- trace(Fx1 + ", " + Fy1)
- stage.showDefaultContextMenu = false;
- Stage.showMenu=false
- }
Add Comment
Please, Sign In to add comment