Last active
September 23, 2015 00:34
-
-
Save albertochiwas/d7fc802e0fa3e41498aa to your computer and use it in GitHub Desktop.
Unidad 2. Operadores y Sentencia if
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 av = new Avatar('squirrel'); | |
av.scale(0.25); | |
//frameRate(30); | |
var x = 0; | |
var y = 0; | |
var izqDer = true; | |
var arrAbajo = true; | |
var pausa = false; | |
var draw = function() { | |
background(200); | |
av.draw(x,y); | |
if ( arrAbajo ) { | |
y = y + random(0,5); | |
} else { | |
y = y - random(0,5); | |
} | |
if (y >= 400) { | |
arrAbajo = false; | |
} else if ( y <= 0 ) { | |
arrAbajo = true; | |
} | |
if ( izqDer ) { | |
x = x + random(0,5); | |
} else { | |
x = x - random(0,5); | |
} | |
if (x >= 400) { | |
izqDer = false; | |
} else if ( x <= 0 ) { | |
izqDer = true; | |
} | |
}; | |
var mouseClicked = function() { | |
pausa = !pausa; | |
if ( pausa ) { | |
noLoop(); | |
} else { | |
loop(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment