Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. function start() {
  2. var a = Randomizer.nextInt(1,100);
  3. println("Guess 1 - 100");
  4.  
  5. while(true) {
  6. var b = readInt("Whats ur guess?");
  7. if(b == a) {
  8. println("Ur guess is correct.");
  9. } else if(b > a) {
  10. println("lower.");
  11. } else {
  12. println("higher.");
  13. }
  14. }
  15. }
  16.  
  17. -----------
  18.  
  19. var NUM_CIRCLES = 30;
  20. var BIG_RADIUS = 150;
  21.  
  22. function start()
  23. {
  24. // Calculate constant values:
  25. var xPos = getWidth()/2;
  26. var height = getHeight();
  27. var increment = BIG_RADIUS / NUM_CIRCLES;
  28.  
  29. // Draw circles:
  30. for (var i = NUM_CIRCLES - 1; i > 0; i--)
  31. {
  32. var circle = new Circle(i * increment);
  33. circle.setColor(Randomizer.nextColor());
  34. circle.setPosition(xPos, height - circle.getRadius());
  35. add(circle);
  36. }
  37. }
  38.  
  39. --------
  40.  
  41. var STARTING_SIZE = getWidth();
  42. var MIN_SIZE = 5;
  43.  
  44. function start()
  45. {
  46. // Calculate initial values:
  47. var width = STARTING_SIZE;
  48. var cx = getWidth() / 2;
  49. var cy = getHeight() / 2;
  50.  
  51. // Draw the structure:
  52. while (width >= MIN_SIZE)
  53. {
  54. // Draw rectangle:
  55. var rect = new Rectangle(width, width);
  56. rect.setColor(Randomizer.nextColor());
  57. rect.setPosition(cx - width/2, cy - width/2);
  58. add(rect);
  59.  
  60. // Draw circle inside rectangle:
  61. var circle = new Circle(width/2);
  62. circle.setColor(Randomizer.nextColor());
  63. circle.setPosition(cx, cy);
  64. add(circle);
  65.  
  66. // Adjust the width for the next pair:
  67. width /= Math.sqrt(2);
  68. }
  69. }
  70.  
  71. ---
  72.  
  73. var cakeWidth = 300;
  74. var cakeHeight = 200;
  75.  
  76. var plateWidth = cakeWidth + 50;
  77. var plateHeight = plateWidth/10;
  78.  
  79. var frostingDropRadius = cakeWidth/24;
  80.  
  81. var candleHeight = cakeHeight/3;
  82. var candleWidth = candleHeight/8;
  83. var candleWickHeight = candleWidth;
  84. var candleWickWidth = candleWidth/4;
  85.  
  86. function start() {
  87.  
  88. var cake = new Rectangle(cakeWidth, cakeHeight);
  89. cake.setColor(Color.ORANGE);
  90. cake.setPosition(getWidth()/2 - cakeWidth/2, getHeight()/2 - cakeHeight/2);
  91. add(cake);
  92.  
  93. var plate = new Rectangle(plateWidth, plateHeight);
  94. plate.setColor(Color.BLUE);
  95. plate.setPosition(getWidth()/2 - plateWidth/2, getHeight()/2 + cakeHeight/2);
  96. add(plate);
  97.  
  98. var numCandles = readInt("How old are you? ");
  99.  
  100. for(var i = 1; i < numCandles + 1; i ++) {
  101. var candle = new Rectangle(candleWidth, candleHeight);
  102. candle.setColor(Color.RED);
  103.  
  104. if (i % 2 == 0) {
  105. candle.setPosition(getWidth()/2-candleWidth*i, cake.getY()-candleHeight);
  106. } else {
  107. candle.setPosition(getWidth()/2+candleWidth*i, cake.getY()-candleHeight);
  108. }
  109. add(candle);
  110. }
  111.  
  112. for(var i = 0; i < 26; i += 2) {
  113. var frosting = new Circle(frostingDropRadius);
  114. frosting.setColor(Color.PURPLE);
  115. frosting.setPosition(cake.getX() + frostingDropRadius*i, cake.getY() + cakeHeight);
  116. add(frosting);
  117. }
  118.  
  119. for(var i = 0; i < 26; i += 2) {
  120. var frosting = new Circle(frostingDropRadius);
  121. frosting.setColor(Color.PURPLE);
  122. frosting.setPosition(cake.getX() + frostingDropRadius*i, cake.getY());
  123. add(frosting);
  124. }
  125.  
  126. var text = new Text("Happy Birthday!", "30pt Arial");
  127. text.setPosition(getWidth()/2 - text.getWidth()/2, getHeight()/2 + text.getHeight()/2);
  128. text.setColor(Color.RED);
  129. add(text);
  130.  
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement