class Time extends Sprite {
    constructor(x, y, totalSeconds = 120, game) {
        super(x, y, 0, 0);
        this.remaining = totalSeconds;
        this.isUI = true; 
        this.game = game;
    }

    update() {
        this.remaining -= 1 / 60; // assuming 60fps
        if (this.remaining <= 0 ){
            this.game.changeLevel(3);
        }
        return false;
    }

    draw(ctx) {
        ctx.fillStyle = 'black';
        ctx.font = '20px Arial';
        ctx.fillText(`Time: ${Math.max(0, Math.floor(this.remaining))}`, this.x, this.y);
    }
}
