Calculator Tools Calculator Tools

Asteroids Arcade Game

Jan 18, 2024

About this app

A fun and interactive web version of the classic arcade game Asteroids. Players can navigate a spaceship, dodge and shoot asteroids, and score points. Designed to be playable on both web and mobile browsers.

Asteroids Game ◀ ▶ ▲ 💥

Put this on your site

Source

ship.js
                    <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Asteroids Game</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<canvas id="gameCanvas" ontouchstart="event.preventDefault()"></canvas>
<div id="mobileControls">
<button id="leftBtn" class="control-btn">&#9664;</button> <!-- Left arrow icon -->
<button id="rightBtn" class="control-btn">&#9654;</button> <!-- Right arrow icon -->
<button id="thrustBtn" class="control-btn">&#9650;</button> <!-- Up arrow icon -->
<button id="fireBtn" class="control-btn">&#128165;</button> <!-- Fire icon (represented by a collision symbol) -->
</div>
<script type="module">
import Game from './Game.js';
window.addEventListener('DOMContentLoaded', (event) => {
const canvas = document.getElementById('gameCanvas');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
const game = new Game(canvas);
game.init();
});
</script>
</body>
</html>