I am trying to make a flappy bird clone and i was woundering how do i make it so that whenever you press the spacebar it increases the score by 1 and doesnt and more than 1 if you hold the space bar?
let y = 200 ;
let score = 1;
function setup() {
createCanvas(400, 400);
}
function draw() {
if (keyIsDown(32)) {
y -= 10;
score += 1;
} else {
y += 5;
}
clear();
fill(255, 255, 0);
background(50, 204, 255);
ellipse(200, y, 50, 50);
fill(0);
textAlign(CENTER, CENTER);
textSize(50);
text(score, 350, 200);
if (y >= 400) {
clear();
background(50, 204, 255)
fill(0)
textAlign(CENTER)
textSize(50)
text("Game Over", 200, 200)
}
}
P.S sorry for the mess