iDragon – A Thrilling JavaScript Game

Table of Contents

Technologies used -
Description

Welcome to iDragon, an engaging and interactive game developed using HTML, CSS, and JavaScript. In this thrilling adventure, players control a dino character that must dodge oncoming obstacles to survive and achieve a high score. The game captures the excitement of fast-paced gameplay, testing players’ reflexes as they navigate the challenges. With vibrant graphics and smooth animations, iDragon provides a delightful gaming experience that keeps players on the edge of their seats.

The game’s mechanics are simple yet addictive. Players can make the dino jump to avoid obstacles using the up arrow key and move left or right using the respective arrow keys. The score increases with every successful dodge, encouraging players to improve their skills and aim for higher points. The game features background music that enhances the gaming atmosphere and sound effects for added excitement when the game is over.

Highlighted Source Code
				
					document.onkeydown = function (e) {
    if (e.keyCode == 38) {
        dino = document.querySelector(".dino")
        dino.classList.add('animateDino')
        setTimeout(() => {
            dino.classList.remove('animateDino')
        }, 700)
    }
    if (e.keyCode == 39) {
        dino = document.querySelector(".dino")
        dinoX = parseInt(window.getComputedStyle(dino, null).getPropertyValue('left'));
        dino.style.left = dinoX + 112 + "px";
    }
    if (e.keyCode == 37) {
        dino = document.querySelector(".dino")
        dinoX = parseInt(window.getComputedStyle(dino, null).getPropertyValue('left'));
        dino.style.left = (dinoX - 112) + "px";
    }
}
				
			

Related Projects

Fun Project

Tic Tac Toe Game

The Interactive Tic Tac Toe Game is a classic two-player game implemented using HTML, CSS, and JavaScript. This engaging application

Read More »