package org.egordorichev.lasttry.world.biome.components;

import com.badlogic.gdx.graphics.g2d.TextureRegion;

import org.egordorichev.lasttry.Globals;
import org.egordorichev.lasttry.LastTry;
import org.egordorichev.lasttry.component.Component;
import org.egordorichev.lasttry.graphics.Graphics;
import org.egordorichev.lasttry.util.Log;
import org.egordorichev.lasttry.world.biome.Biome;

public class BiomeAnimationComponent implements Component {
    private Biome biome;
    private TextureRegion backgroundTextureRegion;
    private float alpha = 0;

    public BiomeAnimationComponent(Biome biome, TextureRegion backgroundTextureRegion) {
        this.biome = biome;
        this.backgroundTextureRegion = backgroundTextureRegion;
    }

    public void fadeIn() {
        this.alpha = (Math.min(1, this.alpha + 0.01f));
    }

    public void fadeInFast() {
        this.alpha = 1f;
    }

    public void fadeOut() {
        this.alpha = (Math.min(1, this.alpha - 0.01f));
    }

    public boolean fadeInIsDone() {
        return this.alpha >= 0.99f;
    }

    public boolean fadeOutIsDone() {
        return this.alpha < 0.01f;
    }

    @Override
    public void render() {
        int i = 0;
        int w = this.backgroundTextureRegion.getRegionWidth();
        int scaledW = (int) (Globals.resolution.x * 2);
        do {
            draw(i);
            w += this.backgroundTextureRegion.getRegionWidth();
            i++;
            //Log.error(w + ":" + Globals.resolution.x);
        } while (scaledW> w);
    }

    public void draw(int offset) {
        Graphics.batch.setColor(1, 1, 1, this.alpha);
        Graphics.batch.draw(this.backgroundTextureRegion, offset * this.backgroundTextureRegion.getRegionWidth(), 0);
        Graphics.batch.setColor(1, 1, 1, 1);
    }
}
@@ -1220,109 +1220,9 @@
 w = 
-this.backgroundTextureRegion.getRegionWidth();%0A        int scaledW = (int) (Globals.resolution.x * 2)
+0
 ;%0A  
@@ -1346,81 +1346,38 @@
     
-    //Log.error(w + %22:%22 + Globals.resolution.x);%0A        %7D while (scaledW
+%7D while (Globals.resolution.x 
 %3E w)

Fix silly mistake for bg rendering