วันอังคารที่ 30 กันยายน พ.ศ. 2557

Report Bug From Assidnment1 (29/09/15)



What's Wrong

ตอนทำการวนลูป i เพื่วน index ของ Array ที่มีชื่อว่า decorate โปรแกรมไม่ฟ้องขึ้นมาแต่ไม่ทำงาน ดังภาพ ซึ่งตามภาพจริงๆแล้วตามที่วางการทำงานโปรแกรมไว้ จะต้องมีวงกลมสีเหลืองขึ้นมาประดับทั้งสองข้าง 



Why did it happen

ตอนทำการวนลูป i เพื่วน index ของ Array ที่มีชื่อว่า decorate สังเกตเงื่อนไขของการวนลูป 

for (int i =0; i>decorate.length; i++) {
    ellipse (decorate[i], 70, 50, 50);
    ellipse (decorate[i], 250, 30, 30);
  }

กำหนดให้ทำการวนลูปเมื่อตัวแปร i มีค่ามากกว่า ความยาวของ Array เป็นเงื่อนไขที่ผิด แต่ถูกตามลักษณะการเขียน เพาะฉะนั้นโปรแกรมจึงไม่ขึ้นมาฟ้อง แต่จะไม่แสดงผล

How do you fix it



จากสาหตุที่กล่าวไป แก้ได้ด้วยวิธีเปลี่ยนเงื่อนไขให้ถูกต้อง โดยกำหนดให้ทำการวนลูปเมื่อตัวแปร i มีค่าน้อยกว่า ความยาวของ Array  และเมื่อมากกว่าหรือเท่ากับความยาวของ array แล้วมันจะหลุดลูป

ลูป

for (int i =0; i < decorate.length; i++) {
    ellipse (decorate[i], 70, 50, 50);
    ellipse (decorate[i], 250, 30, 30);
  }

Report Bug From Assidnment1 (27/09/15)

What's Wrong

ตอนเรียกใช้ฟังก์ชั่น ชื่อว่า void some_snack (emit1, emit2, upDown); โปรแกรมฟ้องขึ้นมาและไม่ทำงาน ดังภาพ





Why did it happen

ตอนเรียกใช้ฟังก์ชั่น ชื่อว่า void some_snack (float emit1, float emit2, int upDown, int text) ใส่ค่า parameter แค่ 3 ตัว โปรแกรมจึง ไม่ทำงาน

How do you fix it

จากฟังก์ชั่นแบบกำหนดเองที่มี parameter ทั้งหมดสี่ตัว แต่เราเรียกใช้ไปแค่ 3 ตัว วิธีแก้เราต้องเรียกใช้ ให้ครบ ตามฟังก์ชั่นดังนี้

ฟังก์ชั่น


void draw () {   
some_snack (emit1, emit2, upDown, text);
}

void some_snack (float emit1, float emit2, int upDown, int text) {
  noStroke ();
  fill (0, 255, 0);
  ellipse (width/2, height/2, emit1+80, upDown);
  strokeWeight (40);
  stroke (0, 255, 0);
  line ((emit2*2), upDown-130, (emit1*3), upDown-130);
  line ((emit1*3), upDown+30, emit2*2, upDown+30);
  fill (0);
  textSize(text);
  text ("Some", (width/2)-50, (height/2)-30);
  text ("snack", (width/2), (height/2)+20);
}

Assignment 1


https://bitbucket.org/unthika_nongbua/assignment_template/raw/b7e6f77f904a15789b3b8d5cca9e2dcfedd7ce22/my_story.java

int door=250;
int smoke= 40;
int cloud = 100;
int page = 350;
int head = 80;
int eye1 = 250;
int eye2 = 150;
float emit1 = 100;
float emit2 = 100;
int upDown = 200;
int text = 26;
int [] decorate = {
  70, 450
};
int frame =0;
void setup () {
  size (500, 300);
}
void draw () {
  switch(frame) {
  case 0:
    cover();
    break;

  case 1:
    draw_house (smoke, door);
    smoke = smoke - 1;

    if (smoke < (-10)) {
      smoke = 40;
    }
    if (mouseX <= (width/2)) {
      door = door-1;
      if (door <= 50) {
        door=250;
      }
    } else {
      door=250;
    }
    break;
  case 2:
    int side = 500;
    int border = 250;
    magicCloud (side, cloud);
    cloud = cloud+1;
    theBook (page, border);

    if (cloud>150) {
      cloud = 100;
    }
    if (mouseX >= (width/2)) {
      page = 350;
    } else {
      page = 150;
      border = 0;
    }
    break;
  case 3:
    drawBody (head, eye1, eye2);
    head++;
    if (head == 100) {
      head = 80;
    }
    if (mouseX == width/2 || mouseY == 50) {
      fill (102);
      textSize (50);
      text ("Teddy", 50, 200);
    }
    eye1 = mouseX;
    eye2 = mouseY;
    break;
  case 4:
    some_snack (emit1, emit2, upDown, text);
    emit1=emit1+0.2;
    emit2=emit2-0.2;

    if (emit1 >= 105) {
      emit1 = 100;
    }
    if (emit2 < 95) {
      emit2 = 100;
    }
    if (mouseY >= (height/2)) {
      upDown = 500;
      emit1 = 300;
      text = 60;
      fill (255, 0, 0);
      textSize (60);
      text ("BIGGER", (width/2)-100, (height)-50);
    } else {
      upDown = 200;
      text = 26;
    }
    break;
  case 5:
    frame = 0;
  }
}
void cover () {
  background (255, 51, 102);
  fill (255);
  textSize (15);
  text (" Press the TAB Bottom to continue", 130, 250);
  textSize (25);
  text ("Unthika Nongbua", 150, 200);
  textSize (47);
  text (" My Story ", (width/2)-100, height/2);
  fill (255, 255, 0);
  noStroke ();
  ellipse (450, 250, 30, 30);
  for (int i =0; i<decorate.length; i++) {
    ellipse (decorate[i], 70, 50, 50);
    ellipse (decorate[i], 250, 30, 30);
  }
}
void draw_house (int smoke, int door) {
  background (255);
  noStroke ();
  fill (255, 153, 153);
  rect (50, 150, 400, 150);
  fill (153, 51, 0);
  triangle (480, 150, 20, 150, 250, 30);
  fill (153, 255, 255);
  quad ((width/2)-50, height, width/2+50, height, width/2+50, height-100, (width/2)-50, height-100);
  fill (255, 255, 0);
  quad ((width/2)-50, height, door+50, height, door+50, height-100, (width/2)-50, height-100);

  fill (0);
  ellipse (door+35, height-50, 30, 20);
  rect (100, 60, 50, 70);
  ellipse (110, smoke+8, 20, 10);
  ellipse (100, smoke-10, 30, 10);
  ellipse (75, smoke-25, 40, 10);
  textSize (47);
  text (" My Dream ", (width/2)-100, (height/2)-10);
  textSize (15);
  text (" Press the RIGHT Bottom to continue", 120, (height/2)+20);
}


void magicCloud (int side, int cloud) {
  background (255);
  noStroke ();
  fill (0, 204, 255);
  //cloud left
  ellipse (side-500, (height/2)+30, cloud-50, cloud-50);
  ellipse (side-490, (height/2)+80, cloud+20, cloud);
  ellipse (side-480, (height/2)+150, cloud+100, cloud+50);

  //cloud right
  ellipse (side, (height/2)+30, cloud-50, cloud-50);
  ellipse (side-10, (height/2)+80, cloud+20, cloud);
  ellipse (side-20, (height/2)+150, cloud+100, cloud+50);
}

void theBook (int page, int border) {
  fill (204, 153, 51);
  quad (width/2, (height/2)-100, width/2, (height/2)+50, (width/2)+100, (height/2)+50, (width/2)+100, (height/2)-100);

  fill (255, 51, 102);
  quad (width/2, (height/2)-100, width/2, (height/2)+50, page, (height/2)+50, page, (height/2)-100);

  stroke (153, 51, 0);
  strokeWeight (10);
  line (border, border-200, border, border-50);

  fill (204, 153, 51);
  textSize (15);
  text ("The Book", (width/2)+20, (height/2)-30);
  textSize (35);
  text (" My Hobby ", (width/2)-100, (height/2)-110);
  textSize (15);
  text (" Press the UP Bottom to continue", 120, (height/2)+90);
}

void drawBody(int head, int eye1, int eye2) {
  background (255);
  noStroke ();
  fill (102, 51, 0);
  ellipse((width/2)-30, (height/2)-90, 30, 40); //ears
  ellipse((width/2)+30, (height/2)-90, 30, 40);
  fill (255);
  ellipse((width/2)-30, (height/2)-85, 10, 20); //in ears
  ellipse((width/2)+30, (height/2)-85, 10, 20);
  fill (102, 51, 0);
  ellipse ((width/2)-10, (height/2)+100, 10, 70); //legs
  ellipse ((width/2)+10, (height/2)+100, 10, 70);
  rect ((width/2)+30, (height/2)+50, 15, 10, 10);//tail
  ellipse (width/2, (height/2)+30, 70, 100); //body
  fill (225, 225, 153);
  ellipse (width/2, (height/2)+30, 40, 70); //in body
  fill (51, 0, 0);
  ellipse ((width/2)-10, height-20, 20, 10); //feet
  ellipse ((width/2)+10, height-20, 20, 10);
  fill (102, 51, 0);
  ellipse (width/2, (height/2)-50, head, head); //haed
  noStroke ();
  fill (255);
  ellipse ((width/2)-15, (height/2)-60, 20, 25);//eyes
  ellipse ((width/2)+15, (height/2)-60, 20, 25);
  fill (0);
  ellipse (eye1-15, eye2-60, 10, 15);//in eyes
  ellipse (eye1+15, eye2-60, 10, 15);
  fill (225, 225, 153);
  arc((width/2), (height/2)-20, 40, 40, PI, 2*PI);//mouth
  arc((width/2), (height/2)-20, 40, 20, 0, PI);//mouth
  fill (153);
  ellipse (width/2, (height/2)-30, 25, 25); //nose
  stroke (102);
  strokeWeight (1.8);
  line (width/2, (height/2)-40, width/2, (height/2)-30);
  curve((width/2)-3, (height/2)-10, width/2, (height/2)-30, (width/2)-9, (height/2)-25, (width/2)-6, (height/2)-60);
  curve((width/2)+3, (height/2)-10, width/2, (height/2)-30, (width/2)+9, (height/2)-25, (width/2)+6, (height/2)-60);
  noStroke();
  fill (0);
  ellipse (width/2, (height/2)-40, 15, 10);
  stroke (0, 0, 255);
  strokeWeight (3);
  noStroke();
  strokeWeight (0);
  textSize (30);
  text (" I Happy ", (width/2)+70, (height/2)-50);
  textSize (15);
  text (" Press the LEFT Bottom to continue", 120, height-5);
  text ("You can take a look into", (width/2)+70, (height/2)-20);
  text ("the eyes of the bear", (width/2)+70, (height/2)-5);
  text ("position.", (width/2)+70, (height/2)+10);
}

void some_snack (float emit1, float emit2, int upDown, int text) {
  background (255);
  noStroke ();
  fill (0, 0, 255);
  textSize (15);
  text ("The last page.", (width/2)-50, height-35);
  text ("Press the Down Bottom to front cover", (width/2)-125, height-20);
  fill (0, 255, 0);
  ellipse (width/2, height/2, emit1+80, upDown);
  strokeWeight (40);
  stroke (0, 255, 0);
  line ((emit2*2), upDown-130, (emit1*3), upDown-130);
  line ((emit1*3), upDown+30, emit2*2, upDown+30);
  fill (0);
  textSize(text);
  text ("Some", (width/2)-50, (height/2)-30);
  text ("snack", (width/2), (height/2)+20);
  fill (0, 0, 255);
  textSize (35);
  text (" I Like ", (width/2)-50, 40);
}
void keyPressed() {
  frame++;
}

ดูการแสดงผลได้ใน :https://bitbucket.org/unthika_nongbua/assignment_template/src/b7e6f77f904a15789b3b8d5cca9e2dcfedd7ce22/my_story.java?at=default


วันพฤหัสบดีที่ 18 กันยายน พ.ศ. 2557

Started for Array


int [] y = {
  500, 400, 300
};

int [] x = {
  100, 200, 300
};

int [] R = {
  255, 153, 0
};

int [] G = {
  0, 255, 51
};

int [] B = {
  153, 0, 255
};

void setup() {
  size(400, 400);
}
void draw() {
  background(255);
  for (int i=0; i<y.length; i++) {
    fill (R[i], G[i], B[i]);
    draw_balloon(x[i], y[i], 50);
    y[i]=y[i]-1;
    if (y[i] <= 0) {
      y[i] = height;
    }
  }
}
void draw_balloon(int x, int y, int z) {
  line(x, y, x, y+50);
  ellipse(x, y, z, z);
}

วันพฤหัสบดีที่ 11 กันยายน พ.ศ. 2557

Print _The Last num.

void setup () {
  print_star (1);
  print_star (2);
  print_star (3);
  print_star (4);
  print_star (5);
}

void print_star (int count) {
  for (int i =1; i<= (count-1); i++) {
      print ("_");
  }
  println (count);
}

Print Star.

void setup () {
  print_star (1);
  print_star (2);
  print_star (3);
  print_star (4);
  print_star (5);
}

void print_star (int count) {
  for (int i =1; i<= count; i++) {
      print ("*");
  }
  println ();
}

Print Num_Num.

void setup () {
  print_star (1);
  print_star (2);
  print_star (3);
  print_star (4);
  print_star (5);
}

void print_star (int count) {
  for (int i =1; i<= (count-1); i++) {
    if (i%2 == 0) {
      print ("_");
    } else {
      print (i);
    }
  }
  println (count);
}

วันพุธที่ 10 กันยายน พ.ศ. 2557

Calculate Income Tax


float income = 501000;
float incomeTax = 0;

void setup () {
  background (255, 51, 102);
  size (180, 50);
}

void draw () {
  if (income >= 150000) {
    if (income >= 15000 && income < 30000) {
      incomeTax = (income*10)/100;
        text ("Income Tax = "+incomeTax, 20, 30);
    }
    if (income >= 30000 && income < 50000) {
      incomeTax = (income*15)/100;
        text ("Income Tax = "+incomeTax, 20, 30);
    }
    if (income >= 50000 && income < 80000) {
      incomeTax = (income*20)/100;
        text ("Income Tax = "+incomeTax, 20, 30);
    }
    if (income >= 80000) {
      incomeTax = (income*25)/100;
        text ("Income Tax = "+incomeTax, 20, 30);
    }
  }
}

Calculate Grade

 

void setup () {
  background (255, 102, 51);
  size (75, 50);
}

void draw () {
  if (point < 50) {
    text ("Get F", 20, 30);
  }
  if (point >= 50 && point < 60) {
    text ("Get D", 20, 30);
  }
  if (point >= 60 && point < 70) {
    text ("Get C", 20, 30);
  }
  if (point >= 70 && point < 80) {
    text ("Get B", 20, 30);
  }
  if (point >= 80 && point < 100) {
    text ("Get A", 20, 30);
  }
}

วันอาทิตย์ที่ 7 กันยายน พ.ศ. 2557

G.C.D


void setup() {
  size(100, 50);
  background (255, 51, 102);
  fill (51, 0, 0);
  text ("G.C.D. is "+gcd(2, 8), 20, 30);
}
int gcd(int x, int y) {
  if (x==0) {
    return y;
  }
  if (y==0) {
    return x;
  }
  if (x>y) {
    return gcd(y, x%y);
  }
  else {
    return gcd (x, y%x);
  }
}

วันพฤหัสบดีที่ 4 กันยายน พ.ศ. 2557

Factorial

 
void setup() {
  size (50, 30);
  background (0, 0, 255);
  text(fac(7), 10, 20);
}
int fac(int n) {
  if (n==1) {
    return 1;
  }
  else {
    return n*fac(n-1);
  }
}

Find Min Value.


void setup () {
  size (100, 50);
  background (255, 0, 0);
}

void draw () {
  int value1 = 28;
  int value2 = 67;

  if (value1 > value2) {
    text ("Min = "+value2, 20, 30);
  }
  if (value1 < value2) {
    text ("Min = "+value1, 20, 30);
  }
  if (value1 == value2) {
    text ("Equal", 20, 30);
  }
}

Quadrant



void setup () {
  size (200, 200);
}

void draw () {
  background (51, 0, 102);
  stroke (255, 51, 102);
  strokeWeight (5);
  line (0, height/2, width, height/2);
  line (width/2, 0, width/2, height);
  if (mouseX >= width/2  && mouseY <= height/2) {
    text ("Quadrant 1", (width/2)+20, (height/2)-50);
  }
  if (mouseX <= width/2  && mouseY <= height/2) {
    text ("Quadrant 2", 20, (height/2)-50);
  }
  if (mouseX <= width/2  && mouseY >= height/2) {
    text ("Quadrant 3", 20, (height/2)+50);
  }
  if (mouseX >= width/2  && mouseY >= height/2) {
    text ("Quadrant 4", (width/2)+20, (height/2)+50);
  }
}

Combine the trees


void setup() {
  size(500, 500);
  background (255);


  Tree(10, 180, 130, 20);
  drawTree_Fah(100, 250, 300);
  draw_Tree_Aey(200, 500);
  Tree(300, 180, 130, 20);
  drawTree_Fah(100, 250, 10);


}
void Tree(int tree_pointX, int tree_pointY, int leaves_diameter, int produce_diameter) {
  noStroke();
  fill(#1B6F17);
  ellipse(tree_pointX+90, tree_pointY, leaves_diameter, leaves_diameter);//leaves
  ellipse(tree_pointX+20, tree_pointY+60, leaves_diameter, leaves_diameter);
  ellipse(tree_pointX+90, tree_pointY+100, leaves_diameter, leaves_diameter);
  ellipse(tree_pointX+170, tree_pointY+100, leaves_diameter, leaves_diameter);
  ellipse(tree_pointX+240, tree_pointY+60, leaves_diameter, leaves_diameter);
  ellipse(tree_pointX+170, tree_pointY, leaves_diameter, leaves_diameter);
  fill(#390303);
  rect(tree_pointX+120, tree_pointY+120, 40, 200);//trunk
  triangle(tree_pointX+120, tree_pointY+145, tree_pointX+60, tree_pointY+80, tree_pointX+130, tree_pointY+120);//branch left
  triangle(tree_pointX+140, tree_pointY+120, tree_pointX+200, tree_pointY+60, tree_pointX+160, tree_pointY+160);//branch right
  triangle(tree_pointX+155, tree_pointY+120, tree_pointX+165, tree_pointY+60, tree_pointX+180, tree_pointY+110);

  fill(#FA9612);
  ellipse(tree_pointX, tree_pointY+85, produce_diameter, produce_diameter);//produce
  ellipse(tree_pointX+40, tree_pointY+30, produce_diameter, produce_diameter);
  ellipse(tree_pointX+60, tree_pointY+160, produce_diameter, produce_diameter);
  ellipse(tree_pointX+135, tree_pointY+45, produce_diameter, produce_diameter);//
  ellipse(tree_pointX+160, tree_pointY-10, produce_diameter, produce_diameter);
  ellipse(tree_pointX+180, tree_pointY+160, produce_diameter, produce_diameter);
  ellipse(tree_pointX+265, tree_pointY+45, produce_diameter, produce_diameter);//

  stroke(#713C18);
  strokeWeight(3);
  line(tree_pointX, tree_pointY+65, tree_pointX, tree_pointY+75);//pedicle
  line(tree_pointX+40, tree_pointY+10, tree_pointX+40, tree_pointY+20);
  line(tree_pointX+60, tree_pointY+140, tree_pointX+60, tree_pointY+150);
  line(tree_pointX+135, tree_pointY+25, tree_pointX+135, tree_pointY+35);
  line(tree_pointX+160, tree_pointY-30, tree_pointX+160, tree_pointY-20);
  line(tree_pointX+180, tree_pointY+140, tree_pointX+180, tree_pointY+150);
  line(tree_pointX+265, tree_pointY+25, tree_pointX+265, tree_pointY+35);
}
void drawTree_Fah(int r, int yPos, int xPos) {
  noStroke();
  fill(#93451E);
  triangle (xPos+20, yPos+250, xPos+70, yPos, xPos+120, yPos+250);
  fill(#2EC639);
  ellipse(xPos+70, yPos, r, r);
  ellipse(xPos+30, yPos+30, r, r);
  ellipse(xPos+110, yPos+30, r, r);
  ellipse(xPos, yPos+70, r+20, r);
  ellipse(xPos+140, yPos+70, r+20, r);
  ellipse(xPos+70, yPos+70, r, r);
}

void draw_Tree_Aey(float grow, float bass) {
  noStroke();
  fill (204, 102, 0);
  quad (170, bass, 330, bass, 300, grow, 200, grow);
  fill (153, 225, 0);
  ellipse (150, grow+50, 200, 200);
  ellipse (350, grow+50, 200, 200);
  ellipse (250, grow, 300, 300);

  fill (255, 51, 0);
  ellipse (130, grow+10, 40, 40);
  ellipse (220, grow+20, 40, 40);
  ellipse (180, grow-80, 40, 40);
  ellipse (300, grow-80, 40, 40);
  ellipse (390, grow+30, 40, 40);
  ellipse (260, grow+100, 40, 40);
}

Draw_grid()

 
void setup () {
  size (300, 300);
  background (255);
  Draw_grid (75);
  Draw_grid (150);
  Draw_grid (225);
}

void Draw_grid (int a) {
  line (0, a, 300, a);
  line (a, 0, a, 300);
}

Give an example showing that draw() is called repeatedly




เราจะเห็นได้ว่าเมื่อเราประกาศฟังก์ชั่น void draw () คำสั่งที่อยู่ภายในฟังก์ชั่นนั้นจะทำงานแบบวนซ้ำไปเรื่อยๆ สังเกตได้จาก มีการบวกค่าเพิ่มขึ้นเรื่อย (รูปภาพมีการเคลื่อนที่) แต่ถ้าเราลองนำไปใส่ในฟังก์ชั่น void setup () จะเรียกใช้เพียงครั้งเดียว ไม่มีการวนซ้ำ (ภาพไม่มีการขยับ)

int move1 = 90;
float move2 = 300;

void setup () {
  size (300, 300);
  background (255);
}
void draw () {
  background (255);
  noStroke ();
  fill (255, 51, 153);
  ellipse (move1, move1, 100, 100);
  stroke (51, 255, 0);
  fill (102, 255, 0);
  ellipse (move2, move2, 80, 80);

  move1++;
  move2--;

  if (move2 == 0) {
      move1 = 90;
      move2 = 300;
    }
}

เราลองเปรียบเทียบเพื่อพิสูจน์ว่า void setup () ไม่มีการวนซ้ำ

int move1 = 90;
float move2 = 300;

void setup () {
  size (300, 300);
  background (255);
  noStroke ();
  fill (255, 51, 153);
  ellipse (move1, move1, 100, 100);
  stroke (51, 255, 0);
  fill (102, 255, 0);
  ellipse (move2, move2, 80, 80);

  move1++;
  move2--;
}
void draw () {

  if (move2 == 0) {
    move1 = 90;
    move2 = 300;
  }
}


Give an example showing that draw() is called after setup()



เราจะเห็นได้ว่า เราจะประกาศฟังก์ชั่น void draw() ก่อน void setup() เสมอ เนื่องมาจาก ฟังก์ชั่น void setup() จะถูกเรียกมาใช้งานก่อนเสมอ ไม่ว่าจะวางอยู่ตรงไหน เพิ่มง่ายในการเขียนไม่ให้สับสนเราจึงประกาศฟังก์ชั่น void draw() ก่อนดังนี้

void setup () {
  size (300, 300);
  background (255);
  strokeWeight (2);
  rect (50, (height/2)-100, 200, 200);
}

void draw () {
  stroke (204, 0, 0);
  strokeWeight (5);
  line (20, height/2, width-20, height/2);
}

ต่อไปนี้จะลองประกาศฟังก์ชั่น void draw () ก่อน void setup () เพื่อให้สังเกตดูว่าลำดับคำสั่งมีความแตกต่างกันหรือไม่อย่างไร ดังที่อธิบายไว้แล้วก่อนหน้านี้

void draw () {
  stroke (204, 0, 0);
  strokeWeight (5);
  line (20, height/2, width-20, height/2);
}
void setup () {
  size (300, 300);
  background (255);
  strokeWeight (2);
  rect (50, (height/2)-100, 200, 200);
}


วันจันทร์ที่ 1 กันยายน พ.ศ. 2557

A Bicycle

 

float driveBicycle = 150;
void setup () {
  size (300, 300);
  background (255);
}

void draw () {
  background (255);
  draw_bicycle (driveBicycle);
  driveBicycle = driveBicycle - 1;
  if (driveBicycle <= 0) {
    driveBicycle =width;
  }
}

void draw_bicycle (float driveBicycle) {
  strokeWeight (10);
  stroke (102, 51, 0);
  line (driveBicycle, (height/2)-30, driveBicycle+30, (height/2)-30);

  stroke (255, 51, 0);
  line (driveBicycle-50, (height/2), driveBicycle+50, (height/2));
  line (driveBicycle-50, (height/2)-100, driveBicycle-50, (height/2)+20);
  line (driveBicycle-50, (height/2)-50, driveBicycle+50, (height/2));

  stroke (0);
  ellipse (driveBicycle-50, (height/2)+50, 70, 70);
  ellipse (driveBicycle+70, (height/2)+30, 100, 100);
  fill (102);
  ellipse (driveBicycle-50, (height/2)+50, 20, 20);
  ellipse (driveBicycle+70, (height/2)+30, 50, 50);

  strokeWeight (15);
  stroke (255, 51, 0);
  line (driveBicycle-70, (height/2)-100, driveBicycle-10, (height/2)-100);
}

The Turtle

 
float moveTutle = 150;

void setup () {
  size (300, 300);
  background (255);
}

void draw () {
  background (255);
  draw_tutle (moveTutle);
  moveTutle = moveTutle - 1;
  if (moveTutle <= 0) {
  moveTutle = height;
  }
}

void draw_tutle (float moveTutle) {
  noStroke ();
  fill (255, 102, 0);
  ellipse ((width/2)-50, moveTutle-40, 20, 10);
  ellipse ((width/2)+50, moveTutle-40, 20, 10);
  ellipse ((width/2)-50, moveTutle+40, 20, 10);
  ellipse ((width/2)+50, moveTutle+40, 20, 10);

  ellipse (width/2, moveTutle-75, 20, 50);

  fill (102, 51, 0);
  ellipse (width/2, moveTutle, 100, 150);
  fill (102, 204, 0);
  ellipse (width/2, moveTutle, 80, 130);
}