#include "chunk.h"
#include <render/render.h>
#include <color.h>

namespace game
{

chunk::chunk(const vec2u &pos)
{
    _pos = pos;
    randomColor = color::hsv2rgba(vec3f(pos.x+pos.y*2, .5,.5), .3);
}

void chunk::setReference(const vec2u &pos, cell *c)
{
    _cells[pos.x][pos.y] = c;
}

void chunk::draw()
{
    for(uint i = _pos.x, x = _pos.x+chunkSize; i < x; i++)
        for(uint j = _pos.y, y = _pos.y+chunkSize; j < y; j++)
            render::primitives2d::quad(vec2f(i,j)-vec2f(0.05), vec2f(1.1), randomColor);
}

}
