#include "tank.hpp"

tank::tank() : sprite()
{
    _sightRadius = 0;
    _rad = 0;
    _a = 0;
}

tank::tank(const shell& model) : sprite(model)
{
    _sightRadius = 20;
}

bool tank::watch(const sprite& hero)
{
    point tmp = _pos- hero.getPos();
    return tmp.magSQ() < _sightRadius*_sightRadius;
}

bullet tank::shoot(const sprite& hero, const shell& model)
{
    _rad+=1;
    if(_rad>60)
    {
        _a++;
        _rad = 0;
    }

    setRad(cos(_a),sin(_a),0);
    bullet tmp(model);
    tmp.setRad(_radX, _radY, _radZ);
    tmp.setPos(_pos + _dir);
    tmp.setSpeed(-0.3);
    tmp.setExpire(30);
    return tmp;
}
