package com.lubjam16.epiceggsmash.game;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

/**
 * Created by stonek on 1/30/16.
 */
public class Animations {
    private static final int    FRAME_COLS = 4;
    private static final int    FRAME_ROWS = 5;

    public static Texture explosionSheet;
    static TextureRegion[] explosionFrames;
    public static Animation explosion;

    public static void init(){
        explosionSheet = new Texture(Gdx.files.internal("explosion2.png"));

        TextureRegion[][] tmp = TextureRegion.split(explosionSheet,
                explosionSheet.getWidth()/FRAME_COLS,
                explosionSheet.getHeight()/FRAME_ROWS);
        explosionFrames = new TextureRegion[FRAME_COLS * FRAME_ROWS];
        int index = 0;
        for (int i = 0; i < FRAME_ROWS; i++) {
            for (int j = 0; j < FRAME_COLS; j++) {
                explosionFrames[index++] = tmp[i][j];
            }
        }

        explosion = new Animation(0.019f, explosionFrames);
    }

    public static void clear(){
        explosionSheet.dispose();
    }
}
