xxxxxxxxxx
40
function displayScore(currentScore, bestScore) {
fill(255);
textSize(10);
text('Score: ' + currentScore, 30, 30); // position for the score
text('Best: ' + bestScore, 30, 50); // position for the best score
}
function showStartScreen() {
fill(255);
textSize(32);
textAlign(CENTER);
text('Press SPACE to Start', width / 2, height / 2 - 40);
textSize(20);
text('Use SPACE to Jump. Avoid Obstacles!', width / 2, height / 2);
}
function showGameOverScreen() {
fill(255);
textSize(32);
textAlign(CENTER);
text('Game Over', width / 2, height / 2 - 40);
text('Your Score: ' + score, width / 2, height / 2);
text('Press 1 to Restart', width / 2, height / 2 + 40);
}
function startGame() {
gameStarted = true;
score = 0; // Resets the score when the game starts
}
function resetGame() {
player = new Player(); // Resets the player
obstacles = []; // Cleasr the obstacle array
score = 0; // Resets the score
upsideDownMode = false; // Resets to normal mode
gameOver = false;
lastObstacleFrame = 0; // Resets frame tracking
loop(); // Restart the game loop
}