// Oliver
using UnityEngine;

public class Map_Generator : MonoBehaviour
{
    public Texture2D tex;
    public int width;
    public int heigt;
    public Color[] pixelFarbe;
    public GameObject blockPrefab;
    void Start()
    {
        width = tex.width;
        heigt = tex.height;

        pixelFarbe = new Color[width * heigt];

        for (int i = 0; i < heigt; i++)
        {
            for (int k = 0; k < width; k++)
            {
                pixelFarbe[k + i * width] = tex.GetPixel(k, i);
            }

        }
        for (int i = 0; i < heigt; i++)
        {
            for (int k = 0; k < width; k++)
            {
                if (pixelFarbe[k + i * width].grayscale >= Color.gray.grayscale)
                {
                    GameObject block = Instantiate(blockPrefab);
                    block.transform.position = new Vector3(k, 0, i);
                    block.GetComponent<Renderer>().material.color = Color.black;
                }

            }
        }
    }

    void Update()
    {

    }
}
