#include "Point.h"

Point::Point(int rayon,Uint32 couleur)
:m_rayon(rayon)
{
    m_pixel = SDL_CreateRGBSurface(SDL_HWSURFACE, 1, 1, 16, 0, 0, 0, 0);
    SDL_FillRect(m_pixel,NULL,couleur);
    if (!m_pixel)
    {
        std::cout << "Impossible de créer la surface dans l'objet Point " << SDL_GetError() << std::endl;
    }
}///Constructeur standard

Point::Point(int rayon,Uint32 couleur,int transparence)
:m_rayon(rayon)
{
    m_pixel = SDL_CreateRGBSurface(SDL_HWSURFACE, 1, 1, 16, 0, 0, 0, 0);
    SDL_FillRect(m_pixel,NULL,couleur);
    if (!m_pixel)
    {
        std::cout << "Impossible de créer la surface dans l'objet Point " << SDL_GetError() << std::endl;
    }
}///Constructeur +transparence

Point::~Point()
{
    SDL_FreeSurface(m_pixel);
    m_pixel=0;
    std::cout << "Destruction du point effective. " << std::endl;
}///Destructeur

int Point::getRayon()
{
    return m_rayon;
}///getRayon

void Point::afficherPoint(SDL_Surface *screen,int const x, int const y)
{
    int distance(0);
    SDL_Rect position;
    for (int i(x-m_rayon); i<=x+m_rayon; i++)
    {
        for (int j(y-m_rayon); j<=y+m_rayon; j++)
        {
            distance = pow(i-x,2)+pow(j-y,2);
            if (distance <= pow(m_rayon,2))
            {
                position.x=i;
                position.y=j;
                SDL_BlitSurface(m_pixel, 0, screen, &position);
            }//test blit
        }//for j
    }//for i
}///afficherPoint