class GamingBoard extends Phaser.Scene {
    constructor() {
        super('GamingBoard');
    }

    preload() {
        if (WIDTH_WINDOW < HEIGHT_WINDOW)
            this.width = WIDTH_WINDOW * 0.8;

        else
            this.width = HEIGHT_WINDOW * 0.8;
        this.cameras.main.setViewport(WIDTH_WINDOW / 10, HEIGHT_WINDOW / 10, this.width, this.width);

    }

    create() {
        this.add.image(0, 0, 'background').alpha = 0.1;

        this.enemy = this.add.circle(this.width * 0.1, this.width * 0.1, this.width * 0.05, 0x6666ff);
        this.myself = this.add.circle(this.width * 0.9, this.width * 0.9, this.width * 0.05, 0xff33cc);

    }

    update(time, delta) {
        super.update(time, delta);
        if (this.enemy.x < this.myself.x)
            this.myself.setX(this.myself.x - 0.5);
        else if (-0.5 < this.enemy.x - this.myself.x < 0.5)
            this.myself.setX(this.myself.x + 0.5);

        if (this.enemy.y < this.myself.y)
            this.myself.setY(this.myself.y - 0.5);
        else if (-0.5 < this.enemy.y - this.myself.y < 0.5)
            this.myself.setY(this.myself.y - 0.5);
    }
}