xxxxxxxxxx
64
function setup() {
createCanvas(400, 400);
frameRate(100);
score =0;
lifesu =0;
}
let value = 0;
function keyPressed() {
if (keyCode === LEFT_ARROW) {
value = -255;
} else if (keyCode === RIGHT_ARROW) {
value = 255;
} else if (keycode === 'null') {
value = 255;
}
}
var x = 0;
var vofe = 500;
var y = 50;
var esx = 150;
var voex = 10;
function draw() {
background(200);
if (x > 0 || x < 350) {
x = x + value / 100;
}
fill(255, 0, 0);
stroke(10);
rect(x, 375, 150, 25);
if (x < 0) {
x = 1;
}
if (x > 250) {
x = 250;
}
fill(0, 0, 0);
y = y + vofe / 100;
esx = esx + (voex / 50);
ellipse(esx, y, 20, 20);
// vofe += 10;
if (esx > 390 || esx < 0) {
voex = voex - 2 * voex;
}
if (y < 10 || y > 360) {
vofe = vofe - 2 * vofe;
voex = random(-100, 100);
if ((esx > x && esx < x + 150) || y < 50) {score ++} else {
esx = 1000;
// resizeCanvas(0, 0);
lifesu ++;
}
}
}