package zero1hd.rhythmbullet.desktop.screens;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.viewport.ExtendViewport;

import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.audio.MusicController;
import zero1hd.rhythmbullet.audio.visualizer.CircularVisualizer;
import zero1hd.rhythmbullet.desktop.audio.PCMObtainer;

public class GameScreen extends ScreenAdapter {
	private AssetManager assets;
	private SpriteBatch batch;
	private ExtendViewport viewport;
	private CircularVisualizer circleVisualizer;
	
	public GameScreen(AssetManager assets, Preferences prefs, MusicController musicController) {
		this.assets = assets;
		batch = new SpriteBatch();
		viewport = new ExtendViewport(RhythmBullet.WORLD_WIDTH, RhythmBullet.WORLD_HEIGHT);
		circleVisualizer = new CircularVisualizer(new PCMObtainer(musicController));
		circleVisualizer.setCenter(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2);
		circleVisualizer.setCamera(viewport.getCamera());
		circleVisualizer.setColor(Color.CYAN.toFloatBits());
		circleVisualizer.applyPositionChanges();
	}
	
	
	@Override
	public void render(float delta) {
		Gdx.gl.glClearColor(0.22f, 0.22f, 0.22f, 1f);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		circleVisualizer.drawVisualizer();
		super.render(delta);
	}
}
