import { Application, Assets, Container, Sprite, Rectangle } from "pixi.js";
import { Game } from "./game";
import { KeyBoardListener } from "../common";

export class Delivery extends Game {
    constructor() {
        super();

        this._gameDesc.text = "Récupère la livraison de club maté !!";
        this._instruction.text = "Utilise les flèches pour te déplacer";

        this._spawnRate = 0.5 * this._difficulty * 0.5; // how many crates spawn each second
        this._fallSpeed = 1 * this._difficulty * 0.3;

        this._crates = [];

        this._spawnHandle = undefined;

        this.gameContainer.layout = { width: "100%", height: "100%" };
    }

    reset() {
        super.reset();

        this._crates = [];
    }

    start() {
        this._spawnHandle = setTimeout(() => {
            this._addCrate();
        }, 1000 / this._spawnRate);
    }

    end(status) {
        super.end(status);
        clearTimeout(this._spawnHandle);
        KeyBoardListener.offKeyDown(this._keyEventHandle);
    }

    _addCrate() {
        const newCrate = Sprite.from("mate_caisse");
        this.newCrate.width = 20;
        this.newCrate.height = 20;
    }

    _animateCrates() {}
}
