Digital Scene Project
penColor("rgb(0,0,255)");
dot(300);
sun();
ground();
grass(15);
function sun() {
//start
penUp();
moveTo(50, 50);
penDown();
//draw main dot of sun
penColor("rgb(255,255,0)");
dot(35);
//draw edge lines of sun
//note: code cannot be looped as every edge is different.
moveTo(70, 80);
turnRight(140);
penWidth(5);
moveForward(17);
turnRight(180);
moveForward(17);
turnRight(70);
moveForward(20);
turnRight(90);
moveForward(20);
turnRight(180);
moveForward(20);
turnRight(65);
moveForward(20);
turnRight(90);
moveForward(21);
turnRight(180);
moveForward(22);
turnRight(50);
moveForward(17);
turnRight(90);
moveForward(24);
turnRight(180);
moveForward(20);
turnRight(50);
moveForward(13);
turnRight(80);
moveForward(20);
turnRight(180);
moveForward(21);
turnRight(80);
moveForward(17);
turnRight(70);
moveForward(25);
turnRight(180);
moveForward(25);
turnRight(70);
moveForward(15);
turnRight(90);
moveForward(31);
turnRight(180);
moveForward(28);
turnRight(65);
moveForward(13);
turnRight(90);
moveForward(30);
turnRight(180);
moveForward(25);
turnRight(65);
moveForward(10);
turnRight(65);
moveForward(25);
turnRight(180);
moveForward(25);
turnRight(75);
moveForward(19);
turnRight(82);
moveForward(29);
turnRight(180);
moveForward(27);
turnRight(65);
moveForward(9);
turnRight(80);
moveForward(29);
turnRight(180);
moveForward(25);
turnRight(90);
moveForward(10);
turnRight(73);
moveForward(25);
penUp();
}
function ground() {
//move to top of ground
moveTo(2, 300);
penDown();
//draw ground as a rectange with a large pen width
penColor("rgb(34,139,34)");
penWidth(136);
turnLeft(75);
moveForward(305);
turnRight(90);
moveForward(135);
turnRight(90);
moveForward(290);
turnRight(90);
moveForward(130);
}
function grass(move) {
penUp();
penWidth(2);
//move to top of ground to create grass
moveTo(2, 235);
penDown();
moveForward(move);
//loop command to create the rest of the grass
for (var i = 0; i < 120; i++) {
moveBackward(move);
turnRight(90);
moveForward(3);
turnLeft(90);
moveForward(move);
}
}
//End of Aidan's code, beginning of Robbie's code
function flower(){
//sets a random size for the flower
x = randomNumber('1', '3') ;
penDown();
// Draws 6 leaves on the flower
for (var i = 0; i < 6; i++) {
leaf (x);
}
//draws the stem
turnTo(180);
penColor("DarkGoldenRod");
moveForward(20*x);
penUp();
}
var x;
//creates one leaf.
function leaf (s){
penColor(c);
penWidth(1);
//Creates the weird, oblong shape of the leaf by drawing pieces of variably sized circles. after each circle segment,
//the turtle turns left, draws a crosshatch, and then returns to it's spot for the next segment.
arcLeft(120, 5*s);
turnLeft(90);
moveForward(9*s);
turnLeft(180);
moveForward(9*s);
turnLeft(90);
arcLeft(60, 4*s);
turnLeft(90);
moveForward(9*s);
turnLeft(180);
moveForward(9*s);
turnLeft(90);
arcLeft(90, 2*s);
turnLeft(90);
moveForward(4*s);
turnLeft(180);
moveForward(4*s);
turnLeft(90);
arcLeft(25, 18*s);
turnLeft(90);
moveForward(9*s);
turnLeft(180);
moveForward(9*s);
turnLeft(90);
}
var c;
//creates the purple flowers, randomly spaced, on the grass section
c = "purple";
penUp();
moveTo(randomNumber(0,150),randomNumber(250,400) );
flower ();
penUp();
moveTo(randomNumber(150,300 ),randomNumber(250,400) );
penDown();
flower () ;
c = "yellow";
penUp();
//creates the yellow flowers
moveTo(randomNumber(0,150),randomNumber(250,400) );
flower ();
penUp();
moveTo(randomNumber(150,300 ),randomNumber(250,400) );
penDown();
flower () ;
//End of Robbie's code, beginning of Jackson's code
hide();
penUp();
moveTo(50, 100);
//Generates a cloud with dot size, max length, max height and rgba
function DrawCloud(size, length, height, r,g,b,a){
penUp();
//Sets pen to inputed rbga value
penColor(rgb(r,g,b,a));
//Loops length times
for(var i=0; i<length; i++){
//Generates random amount of pixels based on the height input
turnTo(0);
var moveDistance = randomNumber(-height, height);
//Creates dots that many pixels above and below the turtle
moveForward(moveDistance);
dot(size);
moveForward(-moveDistance*2);
dot(size);
//Moves back to neutral position with a slight randomized offset
moveForward(moveDistance+ randomNumber(-5, 5));
//Moves forward based off of the length input
turnTo(90);
moveForward(length);
}
}
//Draws all the clouds
function DrawClouds(){
moveTo(10, 60);
//Generates a seed of 3 or 4
var skySeed = randomNumber(3, 4);
//Loops skySeed times
for(var i =0; i<skySeed; i++){
//Generates a seed for the cloud that is smaller if the skySeed is higher
var cloudSeed = randomNumber(20, 30)-(skySeed);
//Draws cloud with right proportions and random alpha value
DrawCloud(cloudSeed, cloudSeed*0.4, cloudSeed, 255,255,255, randomNumber(55, 100)/100);
//Moves forward appropriately
moveForward(cloudSeed*1.5);
}
}
//Draws the head of a sheep with a certain size
function DrawSheepHead(size){
penUp();
//Draws head with "baa baa baa" color
penColor("#bababa");
dot(size);
penColor("#e0e0e0");
//Creates left ear
turnTo(-50);
moveForward(size);
dot(size/2);
//Moves back to center
turnLeft(180);
moveForward(size);
//Creates right ear
turnTo(50);
moveForward(size);
dot(size/2);
//Moves back to center
turnLeft(180);
moveForward(size);
}
//Draws legs of sheep
function DrawSheepLegs(size){
penDown();
penColor("#3f3f3f");
penWidth(5);
//Draws first leg
turnTo(180);
moveForward(size);
turnLeft(90);
//Moves to the second leg position
penUp();
moveForward(size);
//Draws second leg
penDown();
turnLeft(90);
moveForward(size);
penUp();
}
//Draws sheep of different sizes
function DrawSheep(minSize, maxSize){
var bodySeed = randomNumber(minSize, maxSize);
var randomGen = randomNumber(1, 100);
var rgb = 255;
//Black sheep chance
if(randomGen<15){
rgb=130;
}
//Draws a cloud (sheep body)
DrawCloud(bodySeed, bodySeed*0.4, bodySeed, rgb,rgb,rgb, 1);
moveForward(bodySeed);
//Draws head
DrawSheepHead(bodySeed);
//Moves to the back of the sheep
turnTo(-90);
moveForward((bodySeed*0.4)*(bodySeed*0.4)+bodySeed);
//Draws legs
turnTo(180);
moveForward(bodySeed);
DrawSheepLegs(bodySeed*1.85);
}
//Draws all sheep
function DrawAllSheep(){
moveTo(0, 300);
var sheepSeed = randomNumber(2,3);
for(var i=0; i<sheepSeed; i++){
//Draws sheep at size proportional to the sheepSeed
DrawSheep(15 - (sheepSeed), 20 - (sheepSeed));
//Moves to 120 * the sheep its on and a random y value in the grass area
moveTo(120*(i+1), randomNumber(300, 425));
}
}
DrawClouds();
DrawAllSheep();
dot(300);
sun();
ground();
grass(15);
function sun() {
//start
penUp();
moveTo(50, 50);
penDown();
//draw main dot of sun
penColor("rgb(255,255,0)");
dot(35);
//draw edge lines of sun
//note: code cannot be looped as every edge is different.
moveTo(70, 80);
turnRight(140);
penWidth(5);
moveForward(17);
turnRight(180);
moveForward(17);
turnRight(70);
moveForward(20);
turnRight(90);
moveForward(20);
turnRight(180);
moveForward(20);
turnRight(65);
moveForward(20);
turnRight(90);
moveForward(21);
turnRight(180);
moveForward(22);
turnRight(50);
moveForward(17);
turnRight(90);
moveForward(24);
turnRight(180);
moveForward(20);
turnRight(50);
moveForward(13);
turnRight(80);
moveForward(20);
turnRight(180);
moveForward(21);
turnRight(80);
moveForward(17);
turnRight(70);
moveForward(25);
turnRight(180);
moveForward(25);
turnRight(70);
moveForward(15);
turnRight(90);
moveForward(31);
turnRight(180);
moveForward(28);
turnRight(65);
moveForward(13);
turnRight(90);
moveForward(30);
turnRight(180);
moveForward(25);
turnRight(65);
moveForward(10);
turnRight(65);
moveForward(25);
turnRight(180);
moveForward(25);
turnRight(75);
moveForward(19);
turnRight(82);
moveForward(29);
turnRight(180);
moveForward(27);
turnRight(65);
moveForward(9);
turnRight(80);
moveForward(29);
turnRight(180);
moveForward(25);
turnRight(90);
moveForward(10);
turnRight(73);
moveForward(25);
penUp();
}
function ground() {
//move to top of ground
moveTo(2, 300);
penDown();
//draw ground as a rectange with a large pen width
penColor("rgb(34,139,34)");
penWidth(136);
turnLeft(75);
moveForward(305);
turnRight(90);
moveForward(135);
turnRight(90);
moveForward(290);
turnRight(90);
moveForward(130);
}
function grass(move) {
penUp();
penWidth(2);
//move to top of ground to create grass
moveTo(2, 235);
penDown();
moveForward(move);
//loop command to create the rest of the grass
for (var i = 0; i < 120; i++) {
moveBackward(move);
turnRight(90);
moveForward(3);
turnLeft(90);
moveForward(move);
}
}
//End of Aidan's code, beginning of Robbie's code
function flower(){
//sets a random size for the flower
x = randomNumber('1', '3') ;
penDown();
// Draws 6 leaves on the flower
for (var i = 0; i < 6; i++) {
leaf (x);
}
//draws the stem
turnTo(180);
penColor("DarkGoldenRod");
moveForward(20*x);
penUp();
}
var x;
//creates one leaf.
function leaf (s){
penColor(c);
penWidth(1);
//Creates the weird, oblong shape of the leaf by drawing pieces of variably sized circles. after each circle segment,
//the turtle turns left, draws a crosshatch, and then returns to it's spot for the next segment.
arcLeft(120, 5*s);
turnLeft(90);
moveForward(9*s);
turnLeft(180);
moveForward(9*s);
turnLeft(90);
arcLeft(60, 4*s);
turnLeft(90);
moveForward(9*s);
turnLeft(180);
moveForward(9*s);
turnLeft(90);
arcLeft(90, 2*s);
turnLeft(90);
moveForward(4*s);
turnLeft(180);
moveForward(4*s);
turnLeft(90);
arcLeft(25, 18*s);
turnLeft(90);
moveForward(9*s);
turnLeft(180);
moveForward(9*s);
turnLeft(90);
}
var c;
//creates the purple flowers, randomly spaced, on the grass section
c = "purple";
penUp();
moveTo(randomNumber(0,150),randomNumber(250,400) );
flower ();
penUp();
moveTo(randomNumber(150,300 ),randomNumber(250,400) );
penDown();
flower () ;
c = "yellow";
penUp();
//creates the yellow flowers
moveTo(randomNumber(0,150),randomNumber(250,400) );
flower ();
penUp();
moveTo(randomNumber(150,300 ),randomNumber(250,400) );
penDown();
flower () ;
//End of Robbie's code, beginning of Jackson's code
hide();
penUp();
moveTo(50, 100);
//Generates a cloud with dot size, max length, max height and rgba
function DrawCloud(size, length, height, r,g,b,a){
penUp();
//Sets pen to inputed rbga value
penColor(rgb(r,g,b,a));
//Loops length times
for(var i=0; i<length; i++){
//Generates random amount of pixels based on the height input
turnTo(0);
var moveDistance = randomNumber(-height, height);
//Creates dots that many pixels above and below the turtle
moveForward(moveDistance);
dot(size);
moveForward(-moveDistance*2);
dot(size);
//Moves back to neutral position with a slight randomized offset
moveForward(moveDistance+ randomNumber(-5, 5));
//Moves forward based off of the length input
turnTo(90);
moveForward(length);
}
}
//Draws all the clouds
function DrawClouds(){
moveTo(10, 60);
//Generates a seed of 3 or 4
var skySeed = randomNumber(3, 4);
//Loops skySeed times
for(var i =0; i<skySeed; i++){
//Generates a seed for the cloud that is smaller if the skySeed is higher
var cloudSeed = randomNumber(20, 30)-(skySeed);
//Draws cloud with right proportions and random alpha value
DrawCloud(cloudSeed, cloudSeed*0.4, cloudSeed, 255,255,255, randomNumber(55, 100)/100);
//Moves forward appropriately
moveForward(cloudSeed*1.5);
}
}
//Draws the head of a sheep with a certain size
function DrawSheepHead(size){
penUp();
//Draws head with "baa baa baa" color
penColor("#bababa");
dot(size);
penColor("#e0e0e0");
//Creates left ear
turnTo(-50);
moveForward(size);
dot(size/2);
//Moves back to center
turnLeft(180);
moveForward(size);
//Creates right ear
turnTo(50);
moveForward(size);
dot(size/2);
//Moves back to center
turnLeft(180);
moveForward(size);
}
//Draws legs of sheep
function DrawSheepLegs(size){
penDown();
penColor("#3f3f3f");
penWidth(5);
//Draws first leg
turnTo(180);
moveForward(size);
turnLeft(90);
//Moves to the second leg position
penUp();
moveForward(size);
//Draws second leg
penDown();
turnLeft(90);
moveForward(size);
penUp();
}
//Draws sheep of different sizes
function DrawSheep(minSize, maxSize){
var bodySeed = randomNumber(minSize, maxSize);
var randomGen = randomNumber(1, 100);
var rgb = 255;
//Black sheep chance
if(randomGen<15){
rgb=130;
}
//Draws a cloud (sheep body)
DrawCloud(bodySeed, bodySeed*0.4, bodySeed, rgb,rgb,rgb, 1);
moveForward(bodySeed);
//Draws head
DrawSheepHead(bodySeed);
//Moves to the back of the sheep
turnTo(-90);
moveForward((bodySeed*0.4)*(bodySeed*0.4)+bodySeed);
//Draws legs
turnTo(180);
moveForward(bodySeed);
DrawSheepLegs(bodySeed*1.85);
}
//Draws all sheep
function DrawAllSheep(){
moveTo(0, 300);
var sheepSeed = randomNumber(2,3);
for(var i=0; i<sheepSeed; i++){
//Draws sheep at size proportional to the sheepSeed
DrawSheep(15 - (sheepSeed), 20 - (sheepSeed));
//Moves to 120 * the sheep its on and a random y value in the grass area
moveTo(120*(i+1), randomNumber(300, 425));
}
}
DrawClouds();
DrawAllSheep();
Comments
Post a Comment