Advertisement
Guest User

AS2 Code

a guest
Nov 28th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. stop();
  2.  
  3. function addChar(){
  4. char = this.attachMovie("char", "char",_root.getNextHighestDepth());
  5. char._x = 300;
  6. char._y = 200;
  7. }
  8.  
  9. addChar();
  10.  
  11. function addPickup(){
  12. pickup = this.attachMovie("pickup","pickup",_root.getNextHighestDepth());
  13. pickup._x = random(400);
  14. pickup._y = random(300);
  15. }
  16.  
  17. addPickup();
  18.  
  19. function addScore(){
  20. ScoreUp = this.attachMovie("ScoreUp","ScoreUp",_root.getNextHighestDepth());
  21. ScoreUp._x = 120;
  22. ScoreUp._y = 250;
  23. }
  24.  
  25. function addtrail(){
  26. trail = this.attachMovie("trail","trail",_root.getNextHighestDepth());
  27. trail._x = char._x;
  28. trail._y = char._y;
  29. }
  30.  
  31.  
  32. function addblock(){
  33. block = this.attachMovie("block","block",_root.getNextHighestDepth());
  34. block._x = 203;
  35. block._y = 132;
  36. }
  37.  
  38. function addblock2(){
  39. block = this.attachMovie("block2","block2",_root.getNextHighestDepth());
  40. block._x = 483;
  41. block._y = 60;
  42. }
  43.  
  44. addblock2();
  45. addblock();
  46. score = 0;
  47. xSpeed = 0;
  48. ySpeed = 0;
  49. CurrentSpeed = 5;
  50. alive = true
  51.  
  52. char.onEnterFrame = function(){
  53. if(alive){
  54. addtrail();
  55. this._x += xSpeed;
  56. this._y += ySpeed;
  57.  
  58. if(Key.isDown(Key.RIGHT)){
  59. xSpeed = CurrentSpeed;
  60. ySpeed = 0;
  61. }else if(Key.isDown(Key.LEFT)){
  62. xSpeed = -CurrentSpeed;
  63. ySpeed = 0;
  64. }if(Key.isDown(Key.UP)){
  65. ySpeed = -CurrentSpeed;
  66. xSpeed = 0;
  67. }else if(Key.isDown(Key.DOWN)){
  68. ySpeed = CurrentSpeed;
  69. xSpeed = 0;
  70.  
  71. }if(this._x > 520){
  72. xSpeed = -CurrentSpeed;
  73. }if(this._x < 25){
  74. xSpeed = CurrentSpeed;
  75. }if(this._y < 25){
  76. ySpeed = CurrentSpeed;
  77. }if(this._y > 320){
  78. ySpeed = -CurrentSpeed;
  79. }if(this.hitTest(pickup)){
  80. addScore();
  81. removeMovieClip(pickup);
  82. addPickup();
  83. CurrentSpeed += 0.1;
  84. score +=5;
  85. }
  86. }
  87. }
  88.  
  89. movingUp = true;
  90. block.onEnterFrame = function(){
  91. if(this._y < 79 && movingUp){
  92. movingUp = false;
  93. }else if(this._y > 267){
  94. movingUp = true;
  95. }if(movingUp){
  96. this._y --;
  97. }else if(!movingUp){
  98. this._y ++;
  99. }if(char.hitTest(this)){
  100. alive = false
  101. gotoAndStop(3);
  102. removeMovieClip(pickup);
  103. removeMovieClip(char);
  104. removeMovieClip(block);
  105. removeMovieClip(block2);
  106. removeMovieClip(trail)
  107. }
  108. }
  109.  
  110. movingUp2 = true;
  111. block2.onEnterFrame = function(){
  112. if(this._x < 60 && movingUp2){
  113. movingUp2 = false;
  114. }else if(this._x > 483){
  115. movingUp2 = true;
  116. }if(movingUp2){
  117. this._x --;
  118. }else if(!movingUp2){
  119. this._x ++;
  120. }if(char.hitTest(this)){
  121. alive = false
  122. gotoAndStop(3);
  123. removeMovieClip(pickup);
  124. removeMovieClip(char);
  125. removeMovieClip(block2);
  126. removeMovieClip(block);
  127. removeMovieClip(trail)
  128. }
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement