#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 SDL_Surface* createPoint(int rayon,Uint32 couleur) { return createCircle(rayon,couleur,0); }///createPoint SDL_Surface* createCircle(int rayOut,Uint32 couleur,int rayIn) { // [1] Création des composants int diametre(rayOut*2); SDL_Surface* point = SDL_CreateRGBSurface(SDL_HWSURFACE, diametre, diametre, 16, 0, 0, 0, 0); SDL_Surface* pixel = SDL_CreateRGBSurface(SDL_HWSURFACE, 1, 1, 16, 0, 0, 0, 0); SDL_FillRect(pixel,NULL,couleur); int distance(0); int ext(rayOut*rayOut); int ins(rayIn*rayIn); SDL_Rect pos={0,0,0,0}; int x; int y; // [2] Traçage du cercle for (x=-rayOut; x= ins) { pos.x=x+rayOut; pos.y=y+rayOut; SDL_BlitSurface(pixel, 0, point, &pos); }//test blit }//for j }//for i // [3] Traitement transparence SDL_SetColorKey(point,SDL_SRCCOLORKEY,SDL_MapRGB(point->format,0,0,0)); // [4] Renvoi SDL_FreeSurface(pixel); return point; }///createCircle