package de.thdeg.greiner.superpangworld.graphics.immovable;

import de.thdeg.greiner.superpangworld.gameview.GameView;
import de.thdeg.greiner.superpangworld.graphics.base.GameObject;

/**
 * The background for the game.
 */
public class Background extends GameObject {

    private String backgroundImage;

    /**
     * Create a background object.
     *
     * @param gameView the gameView
     */
    public Background(GameView gameView)  {
        super(gameView);
        setPosition(0,0);
        size = 1;
        rotation = 0;
        backgroundImage = "background_1.png";
    }

    @Override
    public void addToCanvas() {
        gameView.addImageToCanvas(backgroundImage,position.x,position.y,size,rotation);
    }

    /**
     * Set the background image. If it differs from the previous one a sound is played.
     *
     * @param backgroundImage the background image
     */
    public void setBackgroundImage(String backgroundImage){
        if(!this.backgroundImage.equals(backgroundImage)){
            this.backgroundImage = backgroundImage;
            gameView.playSound("levelSwitch.wav",false);
        }
    }

    @Override
    public void updateStatus() { }
}
