Skip to content

Instantly share code, notes, and snippets.

@slambert
Created September 8, 2015 18:22
Show Gist options
  • Save slambert/f49901deec248caf5949 to your computer and use it in GitHub Desktop.
Save slambert/f49901deec248caf5949 to your computer and use it in GitHub Desktop.
a robot with red eyes that moves
void setup() {
size(480, 120);
smooth();
background(240);
rectMode(CENTER);
// done with setup
}
void draw() {
background(240); // this keepps the whole thing from redrawing itself
// body and arms
fill(200); // make it grey
rect(mouseX,mouseY,50,30); //body is 50x30
ellipse(mouseX-30,mouseY-5,10,10);
ellipse(mouseX+30,mouseY-5,10,10);
// antennae
line(mouseX+6,mouseY-40,mouseX+6,mouseY-30);
// legs
rect(mouseX-10,mouseY+20,10,10);
rect(mouseX+10,mouseY+20,10,10);
// head
rect(mouseX,mouseY-22.5,40,15); // head is 40x15
// eyes
fill(255); // make the eyes white
ellipse(mouseX-9,mouseY-24.5,5,5);
ellipse(mouseX+9,mouseY-24.5,5,5);
// mouth
rect(mouseX,mouseY-18.5,20,3);
}
void mouseDragged() {
fill(255,0,0); // make the eyes red
ellipse(mouseX-9,mouseY-24.5,5,5);
ellipse(mouseX+9,mouseY-24.5,5,5);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment