daily pastebin goal
3%
SHARE
TWEET

Untitled

a guest Mar 8th, 2018 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         onClipEvent (Load) {
  2.  
  3. jumping = true;
  4. jump = 0;
  5. speed = 0;
  6. maxmove = 15;
  7. attacking = false;
  8. dir =
  9. falling = true;
  10. }
  11.  
  12. onClipEvent (EnterFrame)  {
  13.  
  14. if (!_root.ground.hitTest(this._x, this._y, true) && !jumping) {
  15.  
  16. this._y += 6;
  17. _root._y -= 6;
  18. }
  19.  
  20.  
  21.  
  22. if (_root.dead) {
  23.  
  24. this.gotoAndStop("dead");
  25.  
  26. } else {
  27.  
  28. speed *= .85;
  29. if (speed>0) {
  30.  
  31. dir = "right";
  32.  
  33. } else if (speed<0) {
  34.  
  35. dir = "left";
  36.  
  37. }
  38. if (dir == "right"){
  39.  
  40. this._x += speed;
  41. _root._x -= speed;
  42.  
  43. }
  44. if (dir == "left") {
  45.  
  46. this._x += speed;
  47. _root._x -= speed;
  48.  
  49. }
  50. if (Key.isDown(Key.LEFT)) {
  51.  
  52. if (speed>-maxmove) {
  53.  
  54. speed--;
  55.  
  56. }
  57. this.gotoAndStop("run");
  58. this._xscale = -100;
  59.  
  60. } else if (Key.isDown(Key.RIGHT)) {
  61.  
  62. if (speed<maxmove) {
  63.  
  64. speed++;
  65.  
  66. }
  67. this._xscale = 100;
  68. this.gotoAndStop("run");
  69.  
  70. }
  71. if (speed<1  && speed>-1  && !attacking)  {
  72.  
  73. speed = 0;
  74.  
  75. }
  76. if (Key.isDown(Key.UP) && !jumping) {
  77.  
  78. jumping = true;
  79.  
  80. }
  81. if (jumping) {
  82.  
  83. this.gotoAndStop("jump");
  84. this._y -= jump;
  85. _root._y += jump;
  86. jump -= .5;
  87. if (jump<0) {
  88.  
  89. falling = true;
  90.  
  91. }
  92.  
  93. if (jump<-15) {
  94.  jump = -15;
  95. }
  96. }
  97. if (_root.ground.hitTest(this._x, this._y, true) && falling) {
  98.  
  99. jump = 9;
  100. jumping = false;
  101. falling = false;
  102.  
  103. }
  104. }
  105. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top