Jumping Game
const player = document.querySelector("#player"); const obstacle = document.querySelector("#obstacle"); document.addEventListener("keydown", (event) => { if (event.code === "Space") { player.style.bottom = "50px"; setTimeout(() => { player.style.bottom = "0"; }, 500); } }); setInterval(() => { let random = Math.random() * 400; obstacle.style.left = `${random}px`; }, 1000); #game { width: 400px; height: 400px; position: relative; background-color: #ddd; } #player { width: 50px; height: 50px; background-color: red; position: absolute; bottom: 0; left: 175px; } #obstacle { width: 50px; height: 50px; background-color: black; position: absolute; top: 300px; left: 0; }

Comments

What's hot what's not

Swingrowers - Butterfly (Official Music Video) - ELECTRO SWING