#include <iostream>
#include <ctime>	// pour le nombre aléatoire se basant sur time
#include <cstdlib>
#include <SDL/SDL.h>
#include "constantes.hpp"
#include "cPoint.hpp"





cPoint::cPoint() {
		
	this->aleatoire();

	this->r = 255;
	this->g = 255;
	this->b = 255;

	(this->rect).x = BLOC * (this->x);
	(this->rect).y = BLOC * (this->y);

}




cPoint::cPoint(int x, int y) {
	this->x = x;
	this->y = y;

	this->r = 255;
	this->g = 255;
	this->b = 255;

	(this->rect).x = BLOC * (this->x);
	(this->rect).y = BLOC * (this->y);

}


cPoint::cPoint(int r, int g, int b) {

	this->aleatoire();

	this->r = r;
	this->g = g;
	this->b = b;

	(this->rect).x = BLOC * (this->x);
	(this->rect).y = BLOC * (this->y);
}





int cPoint::get_x() {
	return this->x;
}

void cPoint::set_x(int x) {
	this->x = x;
	(this->rect).x = BLOC * (this->x);
}



int cPoint::get_y() {
	return this->y;
}

void cPoint::set_y(int y) {
	this->y = y;
	(this->rect).y = BLOC * (this->y);
}





void cPoint::affiche(SDL_Surface* pPoint, SDL_Surface* pScreen) {

   // Coloration des surfaces
   SDL_FillRect(pPoint, NULL, SDL_MapRGB(pScreen->format, this->r, this->g, this->b));

   // Blit de la surface à l'écran et affichage
   SDL_BlitSurface(pPoint, NULL, pScreen, &(this->rect));
}



void cPoint::aleatoire() {
	srand(time(NULL));

	this->x = rand() % XMAX;
	this->y = rand() % YMAX;

	(this->rect).x = BLOC * (this->x);
	(this->rect).y = BLOC * (this->y);
}


cPoint::~cPoint() {

}
