Skip to content

Instantly share code, notes, and snippets.

@albertochiwas
Last active September 1, 2017 05:21
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/6d3bc0f20b331645b12287d358657ef7 to your computer and use it in GitHub Desktop.
Save albertochiwas/6d3bc0f20b331645b12287d358657ef7 to your computer and use it in GitHub Desktop.
Ejercicio: Animar personaje para que salude 5 veces http://podcast.itch.edu.mx/live-editor/
var av = new Avatar(2);
av.scale(0.75);
frameRate(35);
var draw = function() {
background(255, 255, 0);
av.setAngle(1, 60);
av.next(2); //av.rotate(2, 1);
println(av.getAngle(2));
if (mouseIsPressed) {
av.setAngle(5,round(random(26,34)));
}
av.draw(mouseX,mouseY);
};
@NuriaReyes
Copy link

NuriaReyes commented Sep 1, 2017

var av = new Avatar(6);
av.scale(0.75);
var d = true;
var i = 0;
var draw = function() {
    
    background(197, 236, 252);
    av.draw(200,200);
    
    if(mouseIsPressed){
        i = 0;
    }
    
    if (i >= 5) { 
        av.setAngle(1, 0);
        av.setAngle(2, 0);
    }
    
    if ( av.getAngle(1) < 90 ) {
        av.rotate(1,2);
    } else {
        if ( d ) {
            if ( av.getAngle(2) > 95 ) { 
                d = false;
            }
            av.rotate(2,2);
        } else {
            if ( av.getAngle(2) < 60 ) {
                d = true;
                i++;
            }
            av.rotate(2,-2);
        }
    }
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment