Created
September 1, 2015 05:23
-
-
Save albertochiwas/d3179a4e9a15b34b32cd to your computer and use it in GitHub Desktop.
First attempt to walk
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
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