Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function start() {
- var a = Randomizer.nextInt(1,100);
- println("Guess 1 - 100");
- while(true) {
- var b = readInt("Whats ur guess?");
- if(b == a) {
- println("Ur guess is correct.");
- } else if(b > a) {
- println("lower.");
- } else {
- println("higher.");
- }
- }
- }
- -----------
- var NUM_CIRCLES = 30;
- var BIG_RADIUS = 150;
- function start()
- {
- // Calculate constant values:
- var xPos = getWidth()/2;
- var height = getHeight();
- var increment = BIG_RADIUS / NUM_CIRCLES;
- // Draw circles:
- for (var i = NUM_CIRCLES - 1; i > 0; i--)
- {
- var circle = new Circle(i * increment);
- circle.setColor(Randomizer.nextColor());
- circle.setPosition(xPos, height - circle.getRadius());
- add(circle);
- }
- }
- --------
- var STARTING_SIZE = getWidth();
- var MIN_SIZE = 5;
- function start()
- {
- // Calculate initial values:
- var width = STARTING_SIZE;
- var cx = getWidth() / 2;
- var cy = getHeight() / 2;
- // Draw the structure:
- while (width >= MIN_SIZE)
- {
- // Draw rectangle:
- var rect = new Rectangle(width, width);
- rect.setColor(Randomizer.nextColor());
- rect.setPosition(cx - width/2, cy - width/2);
- add(rect);
- // Draw circle inside rectangle:
- var circle = new Circle(width/2);
- circle.setColor(Randomizer.nextColor());
- circle.setPosition(cx, cy);
- add(circle);
- // Adjust the width for the next pair:
- width /= Math.sqrt(2);
- }
- }
- ---
- var cakeWidth = 300;
- var cakeHeight = 200;
- var plateWidth = cakeWidth + 50;
- var plateHeight = plateWidth/10;
- var frostingDropRadius = cakeWidth/24;
- var candleHeight = cakeHeight/3;
- var candleWidth = candleHeight/8;
- var candleWickHeight = candleWidth;
- var candleWickWidth = candleWidth/4;
- function start() {
- var cake = new Rectangle(cakeWidth, cakeHeight);
- cake.setColor(Color.ORANGE);
- cake.setPosition(getWidth()/2 - cakeWidth/2, getHeight()/2 - cakeHeight/2);
- add(cake);
- var plate = new Rectangle(plateWidth, plateHeight);
- plate.setColor(Color.BLUE);
- plate.setPosition(getWidth()/2 - plateWidth/2, getHeight()/2 + cakeHeight/2);
- add(plate);
- var numCandles = readInt("How old are you? ");
- for(var i = 1; i < numCandles + 1; i ++) {
- var candle = new Rectangle(candleWidth, candleHeight);
- candle.setColor(Color.RED);
- if (i % 2 == 0) {
- candle.setPosition(getWidth()/2-candleWidth*i, cake.getY()-candleHeight);
- } else {
- candle.setPosition(getWidth()/2+candleWidth*i, cake.getY()-candleHeight);
- }
- add(candle);
- }
- for(var i = 0; i < 26; i += 2) {
- var frosting = new Circle(frostingDropRadius);
- frosting.setColor(Color.PURPLE);
- frosting.setPosition(cake.getX() + frostingDropRadius*i, cake.getY() + cakeHeight);
- add(frosting);
- }
- for(var i = 0; i < 26; i += 2) {
- var frosting = new Circle(frostingDropRadius);
- frosting.setColor(Color.PURPLE);
- frosting.setPosition(cake.getX() + frostingDropRadius*i, cake.getY());
- add(frosting);
- }
- var text = new Text("Happy Birthday!", "30pt Arial");
- text.setPosition(getWidth()/2 - text.getWidth()/2, getHeight()/2 + text.getHeight()/2);
- text.setColor(Color.RED);
- add(text);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement