Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/views/mario-game.njk
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,34 @@
font-size: 20px;
font-family: Arial;
}

#instructions {
position: absolute;
top: 10px;
right: 10px;
color: white;
font-size: 16px;
font-family: Arial;
background: rgba(0, 0, 0, 0.5);
padding: 5px 10px;
border-radius: 5px;
}
</style>
</head>

<body>

<div id="game">
<div id="score">Score: 0</div>
<div id="score">Score: <span id="score-value" aria-live="polite" aria-atomic="true">0</span></div>
<div id="instructions">Press <strong>Space</strong> or <strong>Up Arrow</strong> to jump</div>
<div id="mario"></div>
<div class="ground"></div>
</div>

<script>
const mario = document.getElementById("mario");
const game = document.getElementById("game");
const scoreText = document.getElementById("score");
const scoreValue = document.getElementById("score-value");

let jumping = false;
let score = 0;
Expand Down Expand Up @@ -118,7 +131,7 @@
clearInterval(move);
goomba.remove();
score++;
scoreText.innerText = "Score: " + score;
scoreValue.innerText = score;
} else {
position -= 6;
goomba.style.left = position + "px";
Expand Down
Loading