Advertisement
Guest User

Untitled

a guest
Nov 17th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.52 KB | None | 0 0
  1. stage {
  2. backdrop Sea("gallery:Nature/Sea")
  3. let game = true;
  4. let col = "Red";
  5. let velocity = 2;
  6. let gameSpeed = 8;
  7. let score = 0;
  8. let canJump = false;
  9.  
  10. actor Ball {
  11. costume Green("gallery:Objects/Ball Green")
  12. when stage.started {
  13. this.setPosition(-170, 0);
  14. this.size = 50;
  15. this.show();
  16. this.physics.collisionShape = "circle";
  17. showVariable(ref score);
  18. game = true;
  19. while(game) {
  20. if(!this.touchingActorOrClone(Slider)) {
  21. this.y += velocity;
  22. velocity -= 0.1;
  23. this.wait(0.0001);
  24. }
  25. else {
  26. if(isKeyPressed("up arrow")) {
  27. if(canJump){
  28. score += 1;
  29. canJump = false;
  30. }
  31. this.y += 0.4;
  32. velocity = 3;
  33. }
  34. }
  35. }
  36. }
  37.  
  38. when stage.started{
  39. while(game){
  40. this.wait(5);
  41. gameSpeed -= 0.5;
  42. }
  43. }
  44. when stage.started{
  45. while(game){
  46. if(canJump == false){
  47. this.wait(0.5);
  48. canJump = true;
  49. }
  50. if(this.y < -100){
  51. game = false;
  52. stage.broadcast("end");
  53. this.hide();
  54. }
  55. }
  56. }
  57. }
  58.  
  59. actor Slider {
  60. default costume Red("gallery:Objects/Slider Red")
  61. costume Blue("gallery:Objects/Slider Blue")
  62. when stage.started {
  63. this.setPosition(-140, -50);
  64. this.size = 100;
  65. this.hide();
  66. for(let i = 1; i <= 10; i++) {
  67. createClone(this);
  68. this.x += 100;
  69. }
  70. while(game) {
  71. if(score < 21){
  72. createClone(this);
  73. this.wait(1);
  74. }else{
  75. createClone(this);
  76. this.wait(0.5);
  77. }
  78. }
  79. }
  80. when cloned {
  81. this.setCostume(Math.randomBetween(1, 2));
  82. this.y += Math.randomBetween(-2, 2) * 20;
  83. if(col == "Red") {
  84. if(this.costumeName == "Red") {
  85. this.opacity = 100;
  86. }
  87. if(this.costumeName == "Blue") {
  88. this.opacity = 30;
  89. }
  90. }
  91. if(col == "Blue") {
  92. if(this.costumeName == "Red") {
  93. this.opacity = 30;
  94. }
  95. if(this.costumeName == "Blue") {
  96. this.opacity = 100;
  97. }
  98. }
  99. this.show();
  100. this.glideSecondsTo(gameSpeed,this.x-1100,this.y);
  101. this.deleteClone(this);
  102. }
  103. when stage.keyPressed("left arrow") {
  104. if(this.cloneId == 0) {
  105. col = "Red";
  106. stage.broadcastAndWait("changecolor");
  107. }
  108. }
  109. when stage.keyPressed("right arrow") {
  110. if(this.cloneId == 0) {
  111. col = "Blue";
  112. stage.broadcastAndWait("changecolor");
  113. }
  114. }
  115. when stage.signalReceived("changecolor") {
  116. if(this.cloneId != 0) {
  117. if(col == "Red") {
  118. if(this.costumeName == "Red") {
  119. this.opacity = 100;
  120. }
  121. if(this.costumeName == "Blue") {
  122. this.opacity = 30;
  123. }
  124. }
  125. if(col == "Blue") {
  126. if(this.costumeName == "Red") {
  127. this.opacity = 30;
  128. }
  129. if(this.costumeName == "Blue") {
  130. this.opacity = 100;
  131. }
  132. }
  133. }
  134. }
  135. when cloned {
  136. while(game) {
  137. if(this.touching(Ball)) {
  138. if(this.opacity != 100) {
  139. this.wait(0.1);
  140. this.deleteClone(this);
  141. }
  142. }
  143. }
  144. }
  145.  
  146. when stage.signalReceived("end"){
  147. deleteClone(this);
  148. }
  149. }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement