Skip to content

Instantly share code, notes, and snippets.

@albertochiwas
Created May 31, 2017 02:22
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/8b34329cdff39c98206cf626ac3fb998 to your computer and use it in GitHub Desktop.
Save albertochiwas/8b34329cdff39c98206cf626ac3fb998 to your computer and use it in GitHub Desktop.
Another approach to switch & count arm swing movements
var av = new Avatar(15);
av.scale(0.75);
var dir = true;
var c = 0;
var draw = function() {
if (c > 10) { return; }
background(0, 0, 0, 100);
av.draw(mouseX,mouseY);
if ( av.getAngle(1) < 75 ) {
av.rotate(1,2);
} else {
if ( dir ) {
if ( av.getAngle(2) > 89 ) {
dir = false;
c++;
}
av.rotate(2,2);
} else {
if ( av.getAngle(2) < 50 ) {
dir = true;
c++;
}
av.rotate(2,-2);
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment