Skip to content

Commit

Permalink
nm
Browse files Browse the repository at this point in the history
  • Loading branch information
nidhiupman568 committed Jan 19, 2025
1 parent 33273cc commit 9706d3c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions public/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// JavaScript for Mario Controls
const mario = document.getElementById('mario');

function moveForward() {
mario.style.left = (parseInt(mario.style.left) || 0) + 10 + 'px';
}

function moveBackward() {
mario.style.left = (parseInt(mario.style.left) || 0) - 10 + 'px';
}

function jump() {
mario.style.bottom = '100px';
setTimeout(() => {
mario.style.bottom = '0px';
}, 500);
}

// Event listeners for buttons
document.getElementById('btn_right').addEventListener('click', moveForward);
document.getElementById('btn_left').addEventListener('click', moveBackward);
document.getElementById('btn_jump').addEventListener('click', jump);

0 comments on commit 9706d3c

Please sign in to comment.