Bomber Game GPTo

by yiiBoy

HTML

<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <title>Bomber Game</title>
    <style>
        canvas {
            border: 1px solid black;
            display: block;
            margin: 0 auto;
        }
    </style>
</head>
<body>
    <canvas id="gameCanvas" width="400" height="300"></canvas>
    <script>
        const canvas = document.getElementById('gameCanvas');
        const ctx = canvas.getContext('2d');

        let plane, bomb, buildings, level, gameOver, score, nextLevelMessage, nextLevelPending;

        function initGame() {
            plane = {
                x: 0,
                y: 50,
                width: 50,
                height: 20,
                speed: 2,
                acceleration: 0,
                image: createAirshipImage(),
            };

            bomb = {
                x: 0,
                y: 0,
                width: 10,
                height: 10,
                dropped: false,
                image: createBombImage(),
            };

            buildings = [];
            level = 1;
            gameOver = false;
            score = 0;
            nextLevelMessage = false;
            nextLevelPending = false;

            createBuildings();
        }

        function createAirshipImage() {
            const airshipCanvas = document.createElement('canvas');
            airshipCanvas.width = 50;
            airshipCanvas.height = 20;
            const ctx = airshipCanvas.getContext('2d');

            // Нарисовать дирижабль
            ctx.fillStyle = 'gray';
            ctx.beginPath();
            ctx.ellipse(25, 10, 25, 10, 0, 0, Math.PI * 2);
            ctx.fill();
            ctx.fillStyle = 'red';
            ctx.fillRect(5, 5, 40, 10);
            ctx.fillStyle = 'black';
            ctx.fillRect(10, 8, 30, 4);

            return airshipCanvas;
        }

        function createBombImage() {
            const bombCanvas = document.createElement('canvas');
           ...