Last active
December 22, 2015 06:08
-
-
Save arielchuri/6428473 to your computer and use it in GitHub Desktop.
Here a character moves back and forth.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Variables go first | |
int arloX = 200; | |
int arloY = 350; | |
int fredDir = 0; | |
int look = 0; // extra credit | |
//setup runs once | |
void setup() { | |
size(400, 400); | |
} | |
//draw happens over and over | |
void draw() { | |
background(200); | |
//draw Arlo | |
fill(255); // fill body with white | |
rect(arloX-25, arloY-150, 50, 150); //body | |
rect(arloX-100, arloY-190, 200, 40); // arms | |
ellipse(arloX, arloY-210, 60, 60); // head | |
ellipse(arloX-15, arloY-200, 10, 10); //eyes | |
ellipse(arloX+15, arloY-200, 10, 10); | |
fill(0); // fill pupils with black | |
ellipse(arloX-13-look, arloY-200, 5, 7); //pupils | |
ellipse(arloX+17-look, arloY-200, 5, 7); | |
if (fredDir == 0) { //this code only happens if fred is waxing | |
arloX += 1; //add one to fred | |
if (arloX == 300 ) { // if fred gets to 256 change fredDir | |
fredDir = 1; | |
look = 3; | |
} | |
} | |
if (fredDir == 1) { //this code only happens if fred is waning | |
arloX -= 1; | |
if (arloX == 100) { | |
fredDir = 0; | |
look = 0; | |
} | |
} | |
// println(fred); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment