Wednesday, November 30, 2016

Space Ship Scene Reflection



  1. The purpose of the code is to create a scene in space. It works by calling multiple functions that create objects such as spaceships and planets. The most important features are randomized planets with craters, a ufo, a black hole, and a spaceship with animated fire.

  1. The most difficult part for me was the fire for the spaceship. It had to be animated, and look like fire. I achieved the fiery look by making the fire made out of 2 curves, one to the left and one to the right. I then turned the turtle 180 degrees and repeated it, so it got to the original start position of the flame. I then took a stored variable of the distance away from the center of the ship, and had it return to the center. To animate the flames, I had the draw flames loop for infinity, which made new flames constantly, making it animated.

  1. An abstraction I used was to split up the main function of drawing the spaceship into smaller sub functions. I had a simple main function that was split up into smaller more complex functions. The main function called functions to draw the body of the ship, the top, the rocket, and the flames. The main function also had a parameter to rotate the ship. Functions with parameters are a type of abstraction.


  1. We used collaboration to split up the tasks into manageable chunks. We each had sections of code we chose to make. Collaboration was also used for feedback. Before putting everything in the main code, we shared our result and our team mates gave their feedback on it so it could be improved.

CODE:
function drawShip(angle) {
  hide();
  turnTo(angle);
  drawBody();
  drawTop();
  drawRocket();
  drawFlames();
}
function drawBody() {
  penDown();
  penColor("#FA6323");
  penWidth(20);
  turnLeft(90);
  moveForward(15);
  for (var i = 0; i < 3; i++) {
    turnRight(90);
    moveForward(30);
  }
  turnRight(90);
  moveForward(15);
  turnRight(90);
  moveForward(15);
  dot(21);
  penColor("black");
  dot(15);
  penColor("#FACF23");
  dot(13);
}
function drawTop() {
  penUp();
  penColor("#7A7A7A");
  moveForward(40);
  dot(15);
  moveBackward(10);
  turnRight(90);
  moveForward(15);
  turnLeft(90);
  penDown();
  turnLeft(30);
  for (var i = 0; i < 2; i++) {
    moveForward(30);
    turnLeft(120);
  }
  moveForward(30);
  penUp();
  moveBackward(15);
  turnLeft(90);
  moveBackward(22);
}
function drawRocket() {
  penUp();
  moveBackward(40);
  penColor("#4A4A4A");
  penDown();
  penWidth(15);
  turnLeft(90);
  moveForward(5);
  turnLeft(30);
  moveForward(15);
  turnLeft(150);
  moveForward(30);
  turnLeft(150);
  moveForward(15);
  turnRight(60);
  penUp();
  turnLeft(90);
  moveForward(3);
  turnLeft(90);
}
function drawFlames() {
moveForward(15);
speed(100);
var originalDist;
var arcDist;
for (var i = 0; i < 1; i) {
  turnRight(90);
  penRGB(255, randomNumber(104, 175), 17, 1);
  penWidth(randomNumber(2, 6));
  penDown();
  originalDist = randomNumber(-20, -2);
  arcDist = randomNumber(15,40);
  moveForward(originalDist);
  turnLeft(90);
  arcRight(30, arcDist);
  arcLeft(30, arcDist);
  turnRight(180);
  arcLeft(30, arcDist);
  arcRight(30, arcDist);
  turnRight(180);
  arcLeft(30, arcDist);
  arcRight(30, arcDist);
  turnRight(180);
  arcRight(30, arcDist);
  arcLeft(30, arcDist);
  turnRight(90);
  moveForward(originalDist);
  turnRight(90);
}
}
drawShip(0);

No comments:

Post a Comment