package world;

import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;

import _texture.loader.Textures;
import engine.Game;
import engine.Handler;
import interfaces.GameObject;
import player.Player;
import utils.Utils;

public class Debris implements GameObject  {

	public int x, y, width, height, type;
	public boolean discovered;

	public Debris(int x, int y) {
		this.x = x; this.y = y;
		this.type = Utils.rand.nextInt(7); /* assign it a random sprite */
		Handler.debris.add(this);
	}

	private Graphics2D copy;
	private AffineTransform transform = new AffineTransform();
	public void render(Graphics2D g2d) {
		if(!discovered) return;
		if (Game.dontShowDebris) return;
			copy = (Graphics2D) g2d.create(); transform.setToRotation(-Utils._45 * (Game.rotation - 1), x + width / 2, y + height / 2); copy.transform(transform);

			copy.drawImage(Textures.debrisSheet[type], (int) x, (int) y, null);
			
			copy.dispose();
	}
	
	public void tick() {
		if(!Game.dontShowDebris && !discovered && Player.DISCOVERY.contains(x, y)) discovered = true;
	}

}
