Javascript, HTML, CSS Code
Copy
<html>
<head>
<script type="text/javascript"> window.addEventListener('error', function(event) { var message = JSON.parse(JSON.stringify(event.message)); var source = event.filename; var lineno = event.lineno; var colno = event.colno; var error = event.error; window.parent.postMessage({ type: 'iframeError', details: { message: message, source: source, lineno: lineno, colno: colno, error: error ? error.stack : '' } }, '*'); }); window.addEventListener('unhandledrejection', function(event) { window.parent.postMessage({ type: 'iframePromiseRejection', details: { reason: event.reason } }, '*'); }); </script>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>WW2 Arcade Airplane Game</title>
<meta name="description" content="A World War 2 arcade game where you pilot an airplane against various enemies. Includes power-ups, extra lives, and a high score system.">
<meta name="keywords" content="world war 2, arcade game, airplane, enemies, power-ups, extra lives, high score">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<!-- Built-In Functions for Apps -->
<script type="text/javascript">
var localStoragePrefix = "ct-168115578267513";
var lastSave = 0;
function saveLocal(data) {
if (Date.now() - lastSave < 1000) {
return;
}
let cookie = localStoragePrefix + "=" + JSON.stringify(data) + "; path=" + window.location.pathname + "'; SameSite=Strict";
cookie += "; expires=" + new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 1000).toUTCString();
document.cookie = cookie;
lastSave = Date.now();
}
function loadLocal() {
var cookiePrefix = localStoragePrefix + "=";
var cookieStart = document.cookie.indexOf(cookiePrefix);
if (cookieStart > -1) {
let cookieEnd = document.cookie.indexOf(";", cookieStart);
if (cookieEnd == -1) {
cookieEnd = document.cookie.length;
}
var cookieData = document.cookie.substring(cookieStart + cookiePrefix.length, cookieEnd);
return JSON.parse(cookieData);
}
}
</script>
<script type="text/javascript">
// App Javascript Goes Here
var canvas, ctx, ship, shipImage, enemies, bullets, powerups, score, lives, highScore, gameOver, gameLoop;
function init() {
canvas = document.getElementById("game-canvas");
ctx = canvas.getContext("2d");
ship = { x: canvas.width / 2, y: canvas.height - 50, size: 32, speed: 5 };
shipImage = new Image();
shipImage.src = "https://i.imgur.com/2Q7Dk1r.png";
enemies = [];
bullets = [];
powerups = [];
score = 0;
lives = 3;
gameOver = false;
highScore = loadLocal() || 0;
gameLoop = setInterval(updateGame, 33); // ~30 FPS
canvas.addEventListener("mousemove", moveShip);
canvas.addEventListener("click", fireBullet);
}
function moveShip(event) {
if (gameOver) return;
ship.x = event.clientX - canvas.offsetLeft - ship.size / 2;
}
function fireBullet() {
if (gameOver) return;
bullets.push({ x: ship.x + ship.size / 2, y: ship.y, size: 4, speed: 10 });
}
function updateGame() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
spawnEnemies();
updateEnemies();
updateBullets();
updatePowerups();
drawShip();
drawScore();
drawLives();
checkCollisions();
if (gameOver) {
clearInterval(gameLoop);
showGameOver();
}
}
// Game logic & drawing functions
// ...
</script>
<style>
/* App CSS Goes Here */
body {
background-color: #6699cc;
font-family: 'Press Start 2P', cursive;
}
#game-canvas {
background-color: #111;
display: block;
margin: 50px auto;
border: 5px solid #333;
}
#game-over {
display: none;
text-align: center;
margin: 50px auto;
}
button {
background-color: #333;
border: 2px solid #6699cc;
color: #fff;
padding: 10px 20px;
font-size: 24px;
cursor: pointer;
text-transform: uppercase;
font-family: 'Press Start 2P', cursive;
}
button:hover {
background-color: #6699cc;
}
</style>
<link rel="canonical" href="https://calculator.tools/prompt/91/">
<meta charset="utf-8">
</head>
<body onload="init()">
<div id="main-container" class="container">
<!-- App HTML Goes Here -->
<canvas id="game-canvas" width="800" height="600"></canvas>
<div id="game-over">
<h1>Game Over</h1>
<button onclick="init()">Retry</button>
</div>
</div>
<script type="text/javascript"> var localStoragePrefix = "ct-{{ cachebreaker }}"; var lastSave = 0; function saveLocal(data) { if (Date.now() - lastSave < 1000) { return; } let cookie = localStoragePrefix + "=" + JSON.stringify(data) + "; path=" + window.location.pathname + "'; SameSite=Strict"; cookie += "; expires=" + new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 1000).toUTCString(); document.cookie = cookie; lastSave = Date.now(); } function loadLocal() { var cookiePrefix = localStoragePrefix + "="; var cookieStart = document.cookie.indexOf(cookiePrefix); if (cookieStart > -1) { let cookieEnd = document.cookie.indexOf(";", cookieStart); if (cookieEnd == -1) { cookieEnd = document.cookie.length; } var cookieData = document.cookie.substring(cookieStart + cookiePrefix.length, cookieEnd); return JSON.parse(cookieData); } } </script>
<script type="text/javascript"> window.addEventListener('load', function() { var observer = new MutationObserver(function() { window.parent.postMessage({height: document.documentElement.scrollHeight || document.body.scrollHeight},"*"); }); observer.observe(document.body, {attributes: true, childList: true, subtree: true}); window.parent.postMessage({height: document.documentElement.scrollHeight || document.body.scrollHeight},"*"); }); </script>
</body>
</html>