Advertisement
nutter666

Bull in a China shop

Jul 19th, 2012
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. stop();
  2. var speed:Number = 2;
  3. var grip:int = 100;
  4. var spaceBol:Boolean = false;
  5. var spaceTimer:int = 8;
  6. var gripLoss:int = 2;
  7. var lossTimer:int = 20-speed
  8. var onBull:Boolean = true;
  9.  
  10. var score:int = 0;
  11. var multi:int = 1;
  12. var bestMulti:int = 0;
  13. var gameOverTimer:int = -1;
  14. var kDown:Boolean = false;;
  15.  
  16. var markTarg:Number;
  17.  
  18. var smash:pSmash1 = new pSmash1();
  19.  
  20. stage.addEventListener(Event.ENTER_FRAME,eFrame)
  21. stage.addEventListener(KeyboardEvent.KEY_DOWN, keysDown);
  22. stage.addEventListener(KeyboardEvent.KEY_UP, keysUp);
  23.  
  24. function keysDown(event:KeyboardEvent):void {
  25.     if (event.keyCode == Keyboard.SPACE) {
  26.         spaceBol = true;
  27.     }
  28. }
  29. function keysUp(event:KeyboardEvent):void {
  30.     if (event.keyCode == Keyboard.SPACE) {
  31.         spaceBol = false;
  32.         kDown = false;
  33.     }
  34. }
  35.  
  36. function eFrame(e:Event){
  37. multiTxt.text = "Multiplier : "+ multi.toString();
  38. scoreTxt.text = "Score : "+ score.toString();
  39. speedo.gotoAndStop(Math.round(speed*10))
  40. markTarg = (351 - (grip*3))
  41. if(marker.y < markTarg && onBull){
  42. marker.y += (marker.y / markTarg)
  43. }
  44. else if(marker.y > markTarg && onBull){
  45. marker.y -= (marker.y / markTarg)
  46. }
  47.  
  48. if(spaceTimer > 0 && onBull){
  49. spaceTimer --
  50. }
  51. if(lossTimer > 0 && onBull){
  52. lossTimer --
  53. if(lossTimer <= 0 && onBull){
  54. grip -= gripLoss
  55. lossTimer = 20-speed
  56.    }
  57. }
  58. if(spaceBol && spaceTimer == 0 && !kDown){
  59. kDown = true;
  60. if(dot.rotation > -10 && dot.rotation < 10){
  61. grip += gripLoss * 5
  62. score += 25
  63. multi ++
  64. }
  65. else if(dot.rotation > -20 && dot.rotation < 20){
  66. grip += gripLoss * 3
  67. score += 10
  68. multi ++
  69.     }
  70. else if(dot.rotation > -45 && dot.rotation < 45){
  71. grip += gripLoss * 1
  72. score += 5
  73. multi ++
  74. }
  75. else if(dot.rotation > -70 && dot.rotation < 70){
  76. grip += gripLoss * 0.8
  77. }
  78. else if(dot.rotation > 70 || dot.rotation < -70){
  79. grip -= gripLoss
  80. multi = 1
  81. }
  82. if(grip > 100){
  83. grip = 100
  84. }
  85. if(multi > bestMulti){
  86. bestMulti = multi
  87. }
  88. spaceTimer = 8
  89. }
  90. bullMC.rotation += speed
  91. if(speed < 10 && grip > 0){
  92. speed *= 1.001
  93. }
  94. if(speed > 10){
  95. speed = 10
  96. }
  97. if(grip > 0 && onBull){
  98. dot.rotation += 1.8 * speed
  99. rider.rotation += speed
  100. score += (1*multi)
  101. }
  102. if(grip <= 0){
  103. speed *= 0.99
  104. if(onBull){
  105. rider.gotoAndPlay("thrown")
  106. bullMC.gotoAndStop(1)
  107. onBull = false;
  108. gameOverTimer = 45;
  109. }
  110. if(!onBull && gameOverTimer > 0){
  111. gameOverTimer--
  112. if(gameOverTimer == 0){
  113. stage.removeEventListener(Event.ENTER_FRAME,eFrame)
  114. stage.removeEventListener(KeyboardEvent.KEY_DOWN, keysDown);
  115. stage.removeEventListener(KeyboardEvent.KEY_UP, keysUp);
  116. nextFrame();
  117. }
  118. }
  119. }
  120. if(speed < 1){
  121. speed = 0
  122. }
  123.  
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement