void cursor::setTexture(string cursorPass) { sprite.setTexture(textureManager.get(cursorPass)); sprite.setOrigin((Collision::GetSpriteSize(sprite).x / sprite.getScale().x / 2), (Collision::GetSpriteSize(sprite).y / sprite.getScale().y / 2)); sprite.rotate(-90); sprite.setColor(sf::Color(255, 255, 255, settings.getCursorAplha())); }
// Setters void rotateSprite(float angle) { // sf::FloatRect bounds = mSprite.getLocalBounds(); // mSprite.setOrigin mSprite.rotate(angle); }
void GraphicEngine::transformSprite(sf::Sprite& sprite, const Transformation& t, const Color& color) { if (t.hasPosition()) sprite.setPosition((float)t.getX(), (float)t.getY()); if (t.hasRotation()) sprite.rotate(t.getRotation()); if (color.isUsed()) sprite.setColor(sf::Color(color.getColor())); if (t.hasScale()) sprite.setScale(t.getScaleX(), t.getScaleY()); }
//iterate function draw sf::Sprite& update() { graphTx.update(graph); graphSpr.rotate(rotation * 180. / pi); return graphSpr; }
/** Affiche le monstre la ou il doit etre sur la case, avec le bon angle et la bonne position affiche également les points de vie du moob */ void afficheMonstre (sf::RenderWindow &App, sf::Sprite &SpriteMoob ,Monstre* monMoob,int cote, int offSetX, int offSetY , std::list<Tour*> &listTour) { using namespace std; Case* caseMoob = monMoob->CaseCourante(); drawHexagoneIJ ( caseMoob->getI() , caseMoob->getJ(), SpriteMoob, cote, offSetX, offSetY); //sf::Shape pv = sf::RectangleShape (0,0, 0+monMoob->getPV()/2 ,0,5,sf::Color::Black); sf::RectangleShape pv (sf::Vector2f(5,monMoob->getPV()/2)); pv.setFillColor(sf::Color::Black); /// Moche drawHexagoneIJ ( caseMoob->getI() , caseMoob->getJ(), pv, cote, offSetX, offSetY); // on centre le moob int etape; Direction dtion = monMoob->quelleDirection(etape); // on bouge en fonction de la direction double moobOffSetX=0,moobOffSetY=0,moobAvancement; if ( etape == 0) { moobAvancement = ((1000-monMoob->getAvancement())/1000)*cote*(sqrt(3)); } else { moobAvancement = ((500-monMoob->getAvancement())/1000)*cote*(sqrt(3)); } double angle = 0; switch (dtion) { case Est : { moobOffSetX = moobAvancement; moobOffSetY =0; angle = -90; if ( etape == 0) { moobOffSetX -= (sqrt(3)/2) *cote; } break;} case NordEst : { moobOffSetX = moobAvancement / 2 ; moobOffSetY = -moobAvancement * (sqrt(3)/2) ; if ( etape == 0) { moobOffSetX -= (sqrt(3)/2) *cote /2; moobOffSetY += (sqrt(3)/2) *cote *(sqrt(3)/2); } angle = -30; break;} case NordOuest : { moobOffSetX = -moobAvancement / 2 ; moobOffSetY = -moobAvancement * (sqrt(3)/2) ; if ( etape == 0) { moobOffSetX += (sqrt(3)/2) *cote /2; moobOffSetY += (sqrt(3)/2) *cote *(sqrt(3)/2); } angle = 30; break;} case Ouest : { moobOffSetX = - moobAvancement; moobOffSetY = 0; if ( etape == 0) { moobOffSetX += (sqrt(3)/2) *cote; } angle = 90; break;} case SudOuest : { angle = 160; moobOffSetX = -moobAvancement / 2 ; moobOffSetY = moobAvancement * (sqrt(3)/2) ; if ( etape == 0) { moobOffSetX += (sqrt(3)/2) *cote /2; moobOffSetY -= (sqrt(3)/2) *cote *(sqrt(3)/2); } break;} case SudEst: { angle = -160; moobOffSetX = moobAvancement / 2 ; moobOffSetY = moobAvancement * (sqrt(3)/2) ; if ( etape == 0) { moobOffSetX -= (sqrt(3)/2) *cote /2; moobOffSetY -= (sqrt(3)/2) *cote *(sqrt(3)/2); } break;} } SpriteMoob.move(moobOffSetX,moobOffSetY); //double centreX = SpriteMoob.getSize().x/2; // double centreY = SpriteMoob.getSize().y/2 ; double centreX = SpriteMoob.getTextureRect().width /2 ;// SpriteTower.getTexture().getSize().x/2; double centreY = SpriteMoob.getTextureRect().height/2 ; SpriteMoob.setPosition(centreX,centreY); SpriteMoob.rotate(angle); pv. move(moobOffSetX-centreX,moobOffSetY-centreY); App.draw(pv); App.draw(SpriteMoob); //la gestion de l'attaque n'est pas encore definie if ( monMoob != NULL ) { using namespace std; Case* laCase = monMoob->CaseCourante(); if (laCase != NULL ) { std::list<Tour*>::iterator itt = listTour.begin(); for ( itt; itt != listTour.end() ; ++itt) { if ( (*itt)->getCible() == monMoob) { sf::Vector2<int> ij; sf::Vector2<double>xy; ij.x = (*itt)->getPosition()->getI(); ij.y = (*itt)->getPosition()->getJ(); xy = IJtoXY (ij, cote, offSetX, offSetY); // sf::Shape Line = sf::Shape::Line(SpriteMoob.GetPosition().x,SpriteMoob.GetPosition().y,xy.x,xy.y, 2, sf::Color::Red); // App.Draw(Line); } } } } }
void rotate(float rotation){ mSprite.rotate(rotation); }