示例#1
0
void Canon::rotate(Coordonnees posSouris){
	const float Pi = 3.141592654f;

	float ab = std::abs(this->Sprite.GetPosition().x - posSouris.getX());
	float cb = std::abs(this->Sprite.GetPosition().y - posSouris.getY());
	float ac = std::sqrt(ab*ab + cb*cb);

	float angle = std::acos( ( ab*ab + ac*ac - cb*cb ) / ( 2*ab*ac ) );
	angle = angle / Pi * 180;

	if(posSouris.getX() < this->Sprite.GetPosition().x){
		if(posSouris.getY() < this->Sprite.GetPosition().y){
			//Haut Gauche
			this->Sprite.SetRotation(180-angle);
		}else{
			//Bas Gauche
			this->Sprite.SetRotation(180+angle);
		}
	}else{
		if(posSouris.getY() < this->Sprite.GetPosition().y){
			//Haut Droite
			this->Sprite.SetRotation(angle);
		}else{
			//Bas Droite
			this->Sprite.SetRotation(-angle);
		}
	}
}
示例#2
0
Coordonnees grille::getPos(Coordonnees _pos, int i)
{
	int refX;
	int refY;

	switch(i)
	{
	case 1:
		refX = 5;
		refY = 5;
		break;
	case 2:
		refX = 20;
		refY = 20;
		break;
	case 3:
		refX = 30;
		refY = 30;
		break;
	case 4:
		refX = 100;
		refY = 50;
	}

	int tmpX = refX;
	int tmpY = refY;
	
	while( _pos.getX() > tmpX + refX ) tmpX = tmpX + (refX*2);
	while( _pos.getY() > tmpY + refY ) tmpY = tmpY + (refY*2);

	return Coordonnees(tmpX,tmpY);
}
示例#3
0
void grille::del(Coordonnees _pos)
{
	std::map<Coordonnees, Objet*>::iterator it = this->_Grille.find(_pos);
	
	if(it != this->_Grille.end()) this->_Grille.erase(it);

	if(this->listeCases[(_pos.getX()-5)/10][(_pos.getY()-5)/10] == 1) this->listeCases[(_pos.getX()-5)/10][(_pos.getY()-5)/10] = 0;
}
示例#4
0
Canon::Canon(Coordonnees pos){
	this->Type = 4;
	this->ColorRed = false;

	imageManager *imageMur	= imageManager::getInstance();
	grille *Grille			= grille::getInstance();

	Grille->add(pos, this, 1);

	this->Sprite.SetImage(*imageMur->GetImage("images/canon.psd"));

	this->Sprite.SetCenter(5,5);
	this->Sprite.SetPosition(pos.getX(),pos.getY());
}
示例#5
0
bool  grille::add(Coordonnees _pos, Objet *_obj, int overType)
{
	if(!overType) _pos = this->getPos(_pos,_obj->getType());
	else		  _pos = this->getPos(_pos,overType);
	
	if(this->isFree(_pos,0))
	{
		this->_Grille[_pos] = _obj;
		if(_obj->getType() == 1) this->listeCases[(_pos.getX()-5)/10][(_pos.getY()-5)/10] = 1;
		return true;
	}
	
	return false;
}
示例#6
0
Coordonnees grille::calcBezier(Coordonnees A, Coordonnees B, Coordonnees C, double t)
{
    return Coordonnees(pow((1 - t), 2) * A.getX() + 2 * t * (1 -t) * B.getX() + pow(t, 2) * C.getX() , pow((1 - t), 2) * A.getY() + 2 * t * (1 -t) * B.getY() + pow(t, 2) * C.getY());
}