xxxxxxxxxx
43
// posições
var x =70;
var yChao = 200;
var y = yChao;
var estaPulando = false;
function setup() {
createCanvas(400, 300);
frameRate(30);
}
function draw() {
// desenha cenário
background(30);
stroke(255);
fill(100);
rect(0,yChao+5,400,100);
fill(230)
ellipse(x,y,30,40);
// controle das teclas
if (keyIsDown(RIGHT_ARROW)){
x = x + 6;
}
if (keyIsDown(LEFT_ARROW)){
x = x - 6;
}
if ( keyIsDown(UP_ARROW) && ! estaPulando ) {
y = yChao - 120;
estaPulando = true;
}
if ( estaPulando ) {
if ( y < yChao ) {
y = y + 12;
}
else {
estaPulando = false;
y = yChao;
}
}
}