<html lang="en" style="height: 100%;"><head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Base Game</title>
    <meta name="color-scheme" content="light dark">
    <script src="https://iris.findtruman.io/api/js/Phaser/@3.55.2/phaser.min.js"></script>
    <style>
        body {
            width: 100%;
            height: 100%;
            overflow: hidden;
            margin: 0;
            -webkit-touch-callout: none;
            -webkit-user-select: none;
            -khtml-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            outline: 0;
        }

        #divFindtruman {
            width: 100%;
            height: 100%;
            overflow: hidden;
            margin: 0;
        }

        canvas {
            -webkit-touch-callout: none;
            -webkit-user-select: none;
            -khtml-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            outline: 0;
            -webkit-tap-highlight-color: rgba(255, 255, 255, 0);
        }
    </style>
</head><script id="allow-copy_script" src="chrome-extension://aefehdhdciieocakfobpaaolhipkcpgc/content_scripts/copy.js"></script>

<body style="height: 100%;">
    <div id="divFindtruman"><canvas width="600" height="900" style="width: 420.667px; height: 631px; margin-left: 429px; margin-top: 0px;"></canvas></div>

    <script>
function setupImage(imageObj, width, height, alpha, rotationDeg, flipX, flipY) {
            imageObj.setDisplaySize(width, height)
            imageObj.setRotation(Phaser.Math.DegToRad(rotationDeg))
            imageObj.setAlpha(alpha)
            imageObj.setFlipX(flipX)
            imageObj.setFlipY(flipY)
            if (imageObj.body && imageObj.body.isStatic) {
                return imageObj.refreshBody();
            }
            if (imageObj.body && imageObj.body.immovable) {
                return imageObj.refreshBody();
            }
        }

        class MainScene extends Phaser.Scene {
            constructor() {
                super({ key: "MainScene" });
                this.isGameOver = false;
            }

            preload() {
                this.load.image("player", "https://iris-test.findtruman.io/api/asset/432ae6d6-0cee-4f6c-9549-3badc8476971/2024-09-27/1727423738778.png");
                this.load.image("coin", "https://iris-test.findtruman.io/api/asset/432ae6d6-0cee-4f6c-9549-3badc8476971/2024-09-27/1727423592077.png");
                this.load.image("bomb", "https://iris-test.findtruman.io/api/asset/432ae6d6-0cee-4f6c-9549-3badc8476971/2024-09-27/1727423705780.png");
                this.load.image("heart", "https://iris-test.findtruman.io/api/asset/432ae6d6-0cee-4f6c-9549-3badc8476971/2024-09-27/1727423813360.png");
                this.load.image("background", "https://iris-test.findtruman.io/api/asset/432ae6d6-0cee-4f6c-9549-3badc8476971/2024-09-27/1727423985092.png");
            }

            create() {
                this.background = this.add.image(300, 450, "background");
                setupImage(this.background, 600, 900, 1, 0, false, false);

                this.player = this.physics.add.sprite(300, 850, "player");
                setupImage(this.player, 64, 100, 1, 0, false, false);
                this.player.setCollideWorldBounds(true);

                this.coins = this.physics.add.group();
                this.bombs = this.physics.add.group();

                this.score = 0;
                this.scoreText = this.add.text(16, 16, 'Score: 0', { fontSize: '24px', fill: '#fff', stroke: '#000', strokeThickness: 4 });

                this.timer = 60;
                this.timerText = this.add.text(16, 50, 'Time: 60', { fontSize: '24px', fill: '#fff', stroke: '#000', strokeThickness: 4 });

                this.lives = 3;
                this.hearts = this.add.group();
                for (let i = 0; i < 3; i++) {
                    let heart = this.add.image(480 + i * 40, 30, 'heart');
                    setupImage(heart, 32, 32, 1, 0, false, false);
                    this.hearts.add(heart);
                }

                this.cursors = this.input.keyboard.createCursorKeys();
                this.keyA = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.A);
                this.keyD = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.D);

                this.physics.add.overlap(this.player, this.coins, this.collectCoin, null, this);
                this.physics.add.overlap(this.player, this.bombs, this.hitBomb, null, this);

                this.time.addEvent({ delay: 1000, callback: this.spawnItem, callbackScope: this, loop: true });
                this.time.addEvent({ delay: 1000, callback: this.updateTimer, callbackScope: this, loop: true });
            }

            update() {
                if (this.isGameOver) return;

                if (this.cursors.left.isDown || this.keyA.isDown) {
                    this.player.setVelocityX(-300);
                }
                else if (this.cursors.right.isDown || this.keyD.isDown) {
                    this.player.setVelocityX(300);
                }
                else {
                    this.player.setVelocityX(0);
                }

                if (this.timer <= 0) {
                    this.gameOver('Time\'s up!');
                }
            }

            updateTimer() {
                if (this.isGameOver) return;

                if (this.timer > 0) {
                    this.timer--;
                    this.timerText.setText('Time: ' + this.timer);
                }
            }

            spawnItem() {
                if (this.isGameOver) return;

                let x = Phaser.Math.Between(0, 600);
                if (Phaser.Math.Between(0, 10) > 3) {
                    let coin = this.coins.create(x, 0, 'coin');
                    setupImage(coin, 50, 50, 1, 0, false, false);
                    coin.setVelocityY(200);
                } else {
                    let bomb = this.bombs.create(x, 0, 'bomb');
                    setupImage(bomb, 50, 70, 1, 0, false, false);
                    bomb.setVelocityY(200);
                }
            }

            collectCoin(player, coin) {
                coin.disableBody(true, true);
                this.score += 10;
                this.scoreText.setText('Score: ' + this.score);
            }

            hitBomb(player, bomb) {
                bomb.disableBody(true, true);
                this.lives--;
                if (this.lives >= 0) {
                    this.hearts.getChildren()[this.lives].setVisible(false);
                }
                this.shakeScreen();
                if (this.lives <= 0) {
                    this.gameOver('Game Over');
                }
            }

            shakeScreen() {
                this.cameras.main.shake(100, 0.02);
            }

            gameOver(message) {
                this.isGameOver = true;
                this.physics.pause();
                this.player.setTint(0xff0000);
                let gameOverText = this.add.text(300, 400, message, { fontSize: '64px', fill: '#fff', stroke: '#000', strokeThickness: 4 });
                gameOverText.setOrigin(0.5);
                let finalScoreText = this.add.text(300, 500, 'Final Score: ' + this.score, { fontSize: '32px', fill: '#fff', stroke: '#000', strokeThickness: 4 });
                finalScoreText.setOrigin(0.5);

                let playAgainButton = this.add.text(300, 600, 'Play Again', { fontSize: '32px', fill: '#fff', backgroundColor: '#000' });
                playAgainButton.setOrigin(0.5);
                playAgainButton.setInteractive();
                playAgainButton.on('pointerdown', () => this.restartGame());
            }

            restartGame() {
                this.isGameOver = false;
                this.scene.restart();
            }
        }

        const game = new Phaser.Game({
            type: Phaser.AUTO,
            parent: 'divFindtruman',
            width: 600,
            height: 900,
            backgroundColor: '#000000',
            physics: {
                default: 'arcade',
                arcade: {
                    gravity: { y: 0 },
                    debug: false
                }
            },
            scale: {
                mode: Phaser.Scale.FIT,
                autoCenter: Phaser.Scale.CENTER_BOTH
            },
            scene: [MainScene]
        });
    </script>


</body></html>