import { gameHeight, gameWidth } from "../mainscene/Globals.js";
import { MainScene } from "../mainscene/MainScene.js";

/**
 * Simple class to demonstrate a start screne
 */
export class StartScene extends Phaser.Scene {

    spacebar: Phaser.Input.Keyboard.Key;

    constructor(){
        super({
            key: "StartScene",
            active: true
        });
    }

    preload(){
        this.load.atlas('spritesheet2', 'assets/graphics/spritesheet.png', 'assets/graphics/spritesheet.json');    
    }

    create(){
        let text1 = this.add.text(gameWidth/2, gameHeight*0.2, "Boulder Dash", {
            fontFamily: "sans-serif",
            fontSize: "72px",
            color: "#aaa",
            stroke: "#666",
            strokeThickness: 5,
            align: 'center'
        });
        text1.setOrigin(0.5, 0.5);

        let text2 = this.add.text(gameWidth/2, gameHeight * 0.4, "Press Space to start!", {
            fontFamily: "sans-serif",
            fontSize: "36px",
            color: "#3f3",
            stroke: "#666",
            strokeThickness: 2,
            align: 'center'
        });
        text2.setOrigin(0.5, 0.5);

        this.spacebar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE);
        
    }
    
    update(time: number, delta: number){
        if(this.spacebar.isDown){
            this.scene.start("MainScene");
        }
       
    }

}