class Level2 {
    constructor(game) {
        this.game = game;
        this.enemyCount = 0;
        this.enemyLimit = 0;
        this.steps = [];
    }
    initialize() {
        for (let step of this.steps) {
            step(); // execute each step
        }
    }

    addStep(stepFn) {
        this.steps.push(stepFn);
    }



    addBackground(path) {
        this.game.addSprite(new BackgroundSprite(path, 0, 0, 3000, 600));
    }

    addPlayer(path) {
        const player = new Player(100, 300, 60, 60, path);
        this.game.addSprite(player);
        this.game.camera.follow(player);
        this.game.camera.worldWidth = 3000;
        this.game.camera.worldHeight = 600;
        this.game.camera.x = 0;
        this.game.camera.y = 0;
    }

    addPlatforms() {
        this.game.addSprite(new Platform(0, 550, 3000, 50));
        // Add more platforms if needed
    }

    addEnemies(image) {
        this.game.addSprite(new Enemy(800, 500, 50, 50, image));
        this.game.addSprite(new Enemy(1000, 500, 50, 50, image));
    }

    addEnemyGenerator(image, interval, max) {
        this.game.addSprite(new EnemyGenerator(1200, 500, interval, max, image));
    }

    addEnemyCounter(limit) {
        this.enemyLimit = limit;
    }

    addScore() {
        this.game.addSprite(new Score(20, 30));
    }

    addLife() {
        this.game.addSprite(new Life(20, 60, 3, this.game));
    }

    addTimer() {
        this.game.addSprite(new Time(20, 90, 120, this.game));
    }

    addName(text, color, size) {
        this.game.addSprite(new Name(400, 40, text, color, size));
    }

    addFlag(imagePath) {
        this.game.addSprite(new Flag(2800, 470, 40, 80, imagePath, this.game));
    }
}
function addBackground(pImage){
    level2.addStep(() => level2.addBackground(pImage));
    
}
function addPlayer(pImage){
    level2.addStep(() => level2.addPlayer(pImage));
    
}
function addPlatforms(pImage){
    level2.addStep(() => level2.addPlatforms(pImage));
    
}
function addEnemies(pImage){
    level2.addStep(() => level2.addEnemies(pImage));
    
}
function addEnemyGenerator(pImage, interval, max){
    level2.addStep(() => level2.addEnemyGenerator(pImage, interval, max));
    
}
function addEnemyCounter(limit){
    level2.addStep(() => level2.addEnemyCounter(limit));
    
}
function addScore(){
    level2.addStep(() => level2.addScore());
    
}
function addLife(){
    level2.addStep(() => level2.addLife());
    
}
function addTimer(){
    level2.addStep(() => level2.addTimer());
    
}
function addFlag(pImage){
    level2.addStep(() => level2.addFlag(pImage));
    
}
function addName(text, color, size){
    level2.addStep(() => level2.addName(text, color, size));
    
}