Tuesday, February 2, 2016

Frozen Assignment


  1. The first interesting code required my to draw 10 boxes  all 36 degrees varied only using several lines of code. Here is the code
    for (var count2 = 0; count2 < 10; count2++) {
      for (var count = 0; count < 4; count++) {
        moveForward(100);
        turnRight(90);
      }
      turnRight(36);
  2. The next code builds a parallelogram
    for (var count = 0; count < 2; count++) {
      moveForward(100);
      turnRight(60);
      moveForward(100);
      turnRight(120);
    }
  3. Next, the code creates 4 parralelograms
    for (var count2 = 0; count2 < 4; count2++) {
      for (var count = 0; count < 2; count++) {
        moveForward(100);
        turnRight(60);
        moveForward(100);
        turnRight(120);
      }
      turnRight(90);
    }
  4. This code creates 10 parellograms
    for (var count2 = 0; count2 < 10; count2++) {
      for (var count = 0; count < 2; count++) {
        moveForward(100);
        turnRight(60);
        moveForward(100);
        turnRight(120);
      }
      turnRight(36);
    }

    https://studio.code.org/c/51803719
  5. In addition here is the code to create a circle
    for (var count = 0; count < 360; count++) {
      moveForward(1);
      turnRight(1);
    }
  6. Here is the code to have the lady jump between circles
    for (var count2 = 0; count2 < 10; count2++) {
      // create_a_circle
      for (var count = 0; count < 36; count++) {
        moveForward(10);
        turnRight(10);
      }
      jumpForward(25);
    }
  7. Here is the code to create 20 overlapping circles
    for (var count2 = 0; count2 < 20; count2++) {
      // create_a_circle
      for (var count = 0; count < 36; count++) {
        moveForward(10);
        turnRight(10);
      }
      jumpForward(50);
      turnRight(18);
    }
  8. Here is the code to create a circle within a circle
    // create_a_circle
    for (var count = 0; count < 36; count++) {
      moveForward((10));
      turnRight(10);
    }
    // create_a_circle
    for (var count2 = 0; count2 < 36; count2++) {
      moveForward((5));
      turnRight(10);
    }
  9. Here is the code to create 5 circles inscribed within each other

    for (var count3 = 0; count3 < 5; count3++) {
      // create_a_circle
      for (var count = 0; count < 36; count++) {
        moveForward((10));
        turnRight(10);
      }
      // create_a_circle
      for (var count2 = 0; count2 < 36; count2++) {
        moveForward((5));
        turnRight(10);
      }
      turnRight(72);
    }
  10. Here is the code to make three snowflakes
    for (var count3 = 0; count3 < 3; count3++) {
      // create_a_snowflake_branch
      jumpForward(90);
      turnLeft(45);
      for (var count = 0; count < 3; count++) {
        for (var count2 = 0; count2 < 3; count2++) {
          moveForward(30);
          moveBackward(30);
          turnRight(45);
        }
        turnLeft(90);
        moveBackward(30);
        turnLeft(45);
      }
      turnRight(45);
      turnRight(45);
  11. In addition here the code to create an entire snow flake
    for (var count3 = 0; count3 < 8; count3++) {
      // create_a_snowflake_branch
      jumpForward(90);
      turnLeft(45);
      for (var count = 0; count < 3; count++) {
        for (var count2 = 0; count2 < 3; count2++) {
          moveForward(30);
          moveBackward(30);
          turnRight(45);
        }
        turnLeft(90);
        moveBackward(30);
        turnLeft(45);
      }
      turnRight(45);
      turnRight(45);
  12. Here is the last code that I created

Minecraft Assignmment


  1. Here is the code of first loop to put down a block and move forward.
    for (var count = 0; count < 4; count++)
    {   placeBlock("planksBirch");   moveForward(); }
  2. In addition here is the code that I used to build my house on minecraft
    for (var count = 0; count < 2; count++) {
      moveForward();
      placeBlock("planksBirch");
    }
    turnLeft();
    moveForward();
    placeBlock("planksBirch");
    turnRight();
    for (var count2 = 0; count2 < 2; count2++) {
      moveForward();
      placeBlock("planksBirch");
    }
    turnRight();
    for (var count3 = 0; count3 < 4; count3++) {
      moveForward();
      placeBlock("planksBirch");
    }
    turnRight();
    for (var count4 = 0; count4 < 3; count4++) {
      moveForward();
      placeBlock("planksBirch");}
  3. In addition, this next code made the character plant a bunch of crops
    for (var count = 0; count < 6; count++) {
      plantCrop();
      moveForward();
    }
    turnRight();
    moveForward();
    moveForward();
    turnRight();
    for (var count2 = 0; count2 < 7; count2++) {
      plantCrop();
      moveForward();} 
  4. In this next code we were introduced to if else statements.
    Here is the code:
    for (var count = 0; count < 7; count++) {
      destroyBlock();
      ifLavaAhead(function() {
        placeBlockAhead("cobblestone");
      });
      moveForward();}
  5. This code uses if statements again
    for (var count = 0; count < 2; count++) {
      moveForward();
    }
    destroyBlock();
    ifLavaAhead(function() {
      placeBlockAhead("cobblestone");
    });
    moveForward();
    turnRight();
    destroyBlock();
    ifLavaAhead(function() {
      placeBlockAhead("cobblestone");
    });
    moveForward();
    turnLeft();
    destroyBlock();
    ifLavaAhead(function() {
      placeBlockAhead("cobblestone");
    });
    moveForward();
    turnLeft();
    for (var count2 = 0; count2 < 5; count2++) {
      destroyBlock();
      ifLavaAhead(function() {
        placeBlockAhead("cobblestone");
      });
      moveForward();
    }
  6. For the last code of this assignment I tried to cook the sheep with tnt

Monday, February 1, 2016

Starwars Assignment


  • Piloting the robot.
  1. moveRight();moveRight() // makes the robot move right twice
  2. moveRight(); moveRight(); moveDown();moveDown(); // makes the robot move right twice then it moves down twice
  3. moveRight();moveUp();moveDown();moveRight();
  4. moveDown();moveLeft();moveLeft();moveDown();moveDown();moveLeft();
  5. moveRight();moveRight();moveDown();moveDown();moveLeft();moveDown();
  6. moveDown();moveDown();moveUp();moveRight();moveRight();moveUp();moveDown();moveRight();
  • Videogame
  1. Here is the video of my first code that used a function to command the robot to move when the up and down keys are activated.
  2. Here is the next code 
    function whenUp() {
      goUp();
    }
    function whenDown() {
      goDown();
    }
    function whenRight() {
      goRight();
    }
    function whenLeft() {
      goLeft();
    } // this code allows the robot to go up, left, down, and right at either the command of the arrow keys on the screen or by the keyboard. 
  3. In the next part of the code more functions were given to the robot. The goal was to have 900 points at the very end of the run.
  4.  For this next part here is the code I used.function 
    function whenGetStormtrooper(){ removePoints(100);}
    function whenGetRebelPilot() { addPoints(200);}
    function whenGetMynock() { addPoints(200);}
  5. For this next code. Three pigs were added to the code. Here is the code.
    playSound("R2-D2sound1");
    addCharacter("PufferPig");
    addCharacter("PufferPig");
    addCharacter("PufferPig");
    function whenGetPufferPig() {
      playSound("PufferPigRandom");
      addPoints(1000);
  6. In addition, this next code added 8 different characters.
    addCharacter("Tauntaun");
    addCharacter("Tauntaun");
    addCharacter("Tauntaun");
    addCharacter("Tauntaun");

    function whenGetTauntaun() {
      playSound("TauntaunRandom");
      addPoints(50);
    addCharacter("Mynock");
    addCharacter("Mynock");
    addCharacter("Mynock");
    addCharacter("Mynock");
    addCharacter("Mynock");
    addCharacter("Mynock");
    addCharacter("Mynock");
    addCharacter("Mynock");
    }
  7. In the next code the directions were to multiply the mouses everytime a mouse is caught by R2D2.

    function whenGetMouseDroid(){ addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");addCharacter("MouseDroid");} 
  8. In this code we changed R2D2 into 3CPO and we made him super fast.
    addCharacter("RebelPilot");addCharacter("RebelPilot");
    addCharacter("RebelPilot");
    setDroid("C-3PO");
    setDroidSpeed("fast");
    setBackground("random");
    setMap("random");
    function whenGetRebelPilot(){addCharacter("PufferPig")}
  9. Here is the Code for the video game I designed.
    setBackground("Endor");
    setMap("circle");
    setDroid("R2-D2");
    setDroidSpeed("normal");
    playSound("R2-D2random");
    setDroidSpeed("fast");
    function whenUp() {
      goUp();
    }
    function whenDown() {
      goDown();
    }
    function whenLeft() {
      goLeft();
    }
    function whenRight() {
      goRight();
    }
    addCharacter("RebelPilot");
    function whenGetRebelPilot(){
      addPoints(5);
      setMap("grid");
      setBackground("Hoth");
      addCharacter("Stormtrooper");
      addCharacter("Stormtrooper");
      moveFast("Stormtrooper");
      addCharacter("MouseDroid");
    }

    function whenGetMouseDroid(){
        setDroid("random");
        setDroidSpeed("fast");
        setMap("random");
        addPoints(10);
        setBackground("random");
        addCharacter("Stormtrooper");
        addCharacter("MouseDroid");
        addCharacter("Mynock");}
       
    function whenGetMynock(){
      setDroidSpeed("fast");
      setBackground("random");
      setMap("random");
      addCharacter("Stormtrooper");}
       
        function whenGetStormtrooper(){
        setDroidSpeed("slow");
        addCharacter("MouseDroid");
        addCharacter("Mynock");
        removePoints(10);
        addCharacter("PufferPig");
        }
       
        function whenGetPufferPig(){
          addPoints(10);
          setDroidSpeed("fast");
        }
        function whenGetAllPufferPigs() {
          endGame("win");}