Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
void setup(){

  //Frame Rate is set
  frameRate(30); 
  
  //Rectangle Draw Mode is set
  rectMode(CORNER);
  
  // Screen Size is set
  size(400, 400); 

}


// Main draw function
void draw(){
  

  
  //Screen Background Colour
  background(0);
  
  //Stars
  fill(250); // Star colour set to white
  ellipse(390, 160, 10, 10); /////////////////////////////////////
  ellipse(361, 110, 10, 10); //                                 //
  ellipse(297, 60, 10, 10);  //                                 //
  ellipse(210, 10, 10, 10);  //         Star Positions          //
  ellipse(162, 133, 10, 10); //                                 //
  ellipse(333, 222, 10, 10); //                                 //
  ellipse(45, 60, 10, 10);   //                                 //
  ellipse(90, 160, 10, 10);  //                                 //
  ellipse(130, 60, 10, 10);  /////////////////////////////////////
  
  //Ground
  fill(51, 25, 0); // Ground colour set to brown
  ellipse(200, 400, 500, 100); //Ground size and position
  
  //Robot Parts, All parts follow the mouses x position
  
  //Neck
  fill(100); //Robot neck colour set to grey
  rect(282 + mouseX - 300, 180, 30, 40); // Robot neck size and postion
  
  //Head Part 2
  fill(100); // Head part 2 colour set to grey
  rect(257 + mouseX - 300, 130, 84, 50);//  Head part 2 size and position
  
  //Left Antenna
  fill(100); // Left antenna colour set to grey
  triangle(257 + mouseX - 300, 165, 257 + mouseX - 300, 145, 230 + mouseX - 300, 155); // Left antenna size and position
  
  //Right Antenna
  fill(100); // Right antenna colour set to grey
  triangle(341 + mouseX - 300, 165, 341 + mouseX - 300, 145, 370 + mouseX - 300, 155); // Right antenna size and position
  
  //Head Main
  fill(100); // Main head colour set to grey
  rect(264 + mouseX - 300, 120, 70, 70); // Main head size and position
  
  //Face
  fill(255); //Colour of facial features set to red
  ellipse(mouseX + 18, 140, 10, 10); //Right eye
  ellipse(mouseX - 20, 140, 10, 10); //Left eye
  rect(mouseX - 20, 170, 40, 5); //Mouth
  
  //Left Leg
  fill(100); //Left leg colour set to grey
  rect(265 + mouseX - 300, 300, 20, 90); //Leg size and location
  
  //Right Leg
  fill(100); //Right leg colour set to grey
  rect(315 + mouseX - 300, 300, 20, 90);
  
  //Right foot
  fill(100); //Right foot colour set to grey
  rect(315 + mouseX - 300, 380, 30, 10); // Right foot size and position 
  
  //Left foot
  fill(100); //Left foot colour set to grey
  rect(255 + mouseX - 300, 380, 30, 10); //Left foot size and position
  
  //Right Arm
  fill(100); //Right arm colour set to grey
  rect(350 + mouseX - 300, 230, 60, 30); //Right arm size and position
  
  //Left Arm
  fill(100); //Left arm colour set to grey
  rect(190 + mouseX - 300, 230, 60, 30);//Left arm size and position
  
  //Left Hand and Left Hand Hole
  fill(100); //Left hand colour set to grey
  ellipse(185 + mouseX - 300, 245, 50, 50); //Left hand size and position 
  fill(0); //Left hand hole colour set to black
  ellipse(173 + mouseX - 300, 245 , 30, 30); //left hand hole size and position
  
  //Right Hand and Right Hand Hole
  fill(100); // Right hand colour set to grey
  ellipse(420 + mouseX - 300, 245, 50, 50);// Right hand size and position
  fill(0); //Right hand hole colour set to black
  ellipse(432 + mouseX - 300, 245, 30, 30); //Right hand hole size and position
  
  //Body and Body Features
  fill(100); //Main body colour set to grey
  rect(250 + mouseX - 300, 200, 100, 150); //Main body size and position
  rect(260 + mouseX - 300, 220, 80, 120); //Body rectangle size and position
  fill(250, 250, 200); // Light on body colour set to yellowish white
  rect(270 + mouseX - 300, 240, 60, 10); // Light on body size and position
  fill(250, 0, 0); // Button on body colour set to red
  rect(275 + mouseX - 300, 255, 10, 10); // Button size and position
  fill(250, 250, 0);// Button on body colour set to yellow
  rect(295 + mouseX - 300, 255, 10, 10);// Button size and position
  fill(0, 250, 0);// Button on body colour set to green
  rect(315 + mouseX - 300, 255, 10, 10);// Button size and position
}; //End of Main Draw Function

//When the mouse is clicked
void mousePressed(){
  
  //Frame Rate
  frameRate(1);
  
  // Face changes
  fill(250, 0, 0); //Facial features colour and lazers set to red
  ellipse(mouseX + 18, 140, 10, 10); //Right eye size and position
  ellipse(mouseX - 20, 140, 10, 10); //Left eye size and position
  rect(mouseX - 20, 170, 40, 5); //Mouth size and position
  triangle(mouseX - 30, 133, mouseX - 30, 128, mouseX - 15, 133); //Left eyebrow size and position
  triangle(mouseX + 30, 133, mouseX + 30, 128, mouseX + 15, 133); //Right eyebrow size and position
  
  //Lazers
  triangle(470 + mouseX - 350, 255, 470 + mouseX - 350, 235, mouseX + 8, mouseY + 8); //Right Lazer
  triangle(235 + mouseX - 350, 255, 235 + mouseX - 350, 235, mouseX + 8, mouseY + 8); //Left Lazer
  
  //Print Warning Message
  println("DONT TOUCH ME!!!");
  println("*ZAP ZAP*");
  
} //End of Function