Skip to content

Instantly share code, notes, and snippets.

@albertochiwas
Created September 1, 2015 05:23
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 albertochiwas/d3179a4e9a15b34b32cd to your computer and use it in GitHub Desktop.
Save albertochiwas/d3179a4e9a15b34b32cd to your computer and use it in GitHub Desktop.
First attempt to walk
var sr = new Avatar("squirrel");
var x=0, y=0;
var up=true, pause=false;
var draw = function() {
background(255);
if ( up && sr.getAngle(1)<120 ) {
sr.rotate(1, 1);
sr.rotate(3, -1);
} else {
up = false;
}
if ( !up && sr.getAngle(1)>0 ) {
sr.rotate(1, -1);
sr.rotate(3, 1);
} else {
up = true;
}
sr.draw(x,200+y);
x = (x + 1) % 400;
y = 10*sin(10*x);
};
var mouseClicked = function() {
if (pause) {
loop();
} else {
noLoop();
}
pause = !pause;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment