Skip to content

Instantly share code, notes, and snippets.

@simplyluke
Created January 18, 2015 03:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simplyluke/239ab3989c5964039dfa to your computer and use it in GitHub Desktop.
Save simplyluke/239ab3989c5964039dfa to your computer and use it in GitHub Desktop.
don't nobody got no mr roboto
/* ---------------------------------------------------------------------------
Interactive robot.
Command ref:
* click to get an "explosion" under your key and make his eyes flash red
* Down arrow makes his whole head red
* Left arrow makes him raise his right arm
* Press 'b' or "B" to make the background white instead of black
* Press '8' to make him look up
* Press 'j' to make him jump up
--------------------------------------------------------------------------- */
void setup() {
size(400,600);
}
void draw() {
// if you press b the background becomes white
if ((keyPressed) && ((key == 'b') || (key == 'B'))) {
background(255);
} else {
background(0); // BLACK
}
fill(#27586b); // BLUE
// make him jump
if ((keyPressed) && (key == 'j')) {
translate(0, -20);
}
// head
// if down arrow than make his whole face & ears red. otherwise keep blue
if ((keyPressed) && (key == CODED) && (keyCode == DOWN)) {
fill(#ff0724); // RED
}
rect(150, 50, 100, 100);
//ears
triangle(150, 50, 175, 25, 200, 50); // LEFT
triangle(200, 50, 225, 25, 250, 50); // RIGHT
fill(#27586b); // BLUE
// raise left arm
if ((keyPressed) && (key == CODED) && (keyCode == LEFT)) {
rect(100, 100, 25, 100);
} else {
rect(100, 150, 25, 210); // LEFT
}
// Arms
rect(275, 150, 25, 210); // RIGHT
// Legs
rect(125, 350, 45, 150); // LEFT
rect(230, 350, 45, 150); // RIGHT
// Body
rect(125, 150, 150, 200);
fill(#ffffff); // WHITE
// mouth
rect(175, 120, 50, 10);
if (mousePressed) {
fill(#ff0724); // RED
ellipse(mouseX, mouseY, 50, 50);
}
else {
fill(255); // ALSO WHITE
}
// eyes
if ((keyPressed) && (key == '8')) {
translate(0, -5);
}
ellipse(170, 85, 15, 15); // LEFT
ellipse(230, 85, 15, 15); // RIGHT
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment