#include "bot.hpp"

//initialisation
void bot::init(int col, int row, const int w, const int h)
{
	_col=col;
	_row=row;
	type = 0;
	_w=w;
	_h=h;
}

//bouge au coordonné absolut
void bot::absMove(int col, int row)
{
	_col = col;
	_row = row;
}

//avance de vx,vy par rapport au point ou il est
void bot::relMove(int vx, int vy)
{
	_col+=vx;
	_row+=vy;
}

//retourne l'index par rapport a un tableau 40*25 avec les coordonnés relatives
int bot::indexWithRel(int vx, int vy)
{
	//return indexFromXY<_W,_H>(_col+vx, _row+vy);<
	return _col+vx + ((_row+vy)*_w);
}

//retourne l'index par rapport a un tableau 40*25
int bot::index()
{
	//return indexFromXY<_W,_H>(_col, _row);
	return _col + (_row*_w);
}

//retourne la coordonné horizontale au tableau
int bot::col()
{
	return _col;
}

//retourne la coordonné verticale au tableau
int bot::row()
{
	return _row;
}

//test la collision avec une modification hypothetique
bool bot::collideWithRel(bot * it, int vx, int vy)
{
    return (it->index() == indexWithRel(vx,vy));
}
