1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
void RotationSdl(SdlJeu *sj, SDL_Surface * ecran, int xtank, int ytank, int xtourelle, int ytourelle, int type)
{
SDL_Surface * rotation = NULL;
double angle=45;
SDL_Rect pos;
pos.x=xtourelle;
pos.y=ytourelle;
{
if(type==2)
{
/*angle=tan(fabs(ytourelle-ytank)/fabs(xtourelle-xtank));*/
rotation=rotozoomSurface(sj->image->imgtourelle[6], angle, 1.0, 1);
SDL_SetColorKey(rotation,(SDL_SRCCOLORKEY|SDL_RLEACCEL), SDL_MapRGB(rotation->format, 0, 0, 0));
SDL_SetAlpha(rotation, SDL_RLEACCEL, 0);
AffichageImageSdlJeu (rotation, ecran, xtourelle, ytourelle);
pos.x = xtourelle - rotation->w / 2; //Test du positionnement de l'image en fonction de la taille
pos.y = ytourelle - rotation->h / 2;
angle++;
}
if(type==3)
{
/*angle=tan(fabs(ytourelle-ytank)/fabs(xtourelle-xtank));*/
rotation=rotozoomSurface(sj->image->imgtourelle[8], angle, 1.0, 1);
SDL_SetColorKey(rotation,(SDL_SRCCOLORKEY|SDL_RLEACCEL), SDL_MapRGB(rotation->format, 0, 0, 0));
SDL_SetAlpha(rotation, SDL_RLEACCEL, 0);
AffichageImageSdlJeu (rotation, ecran, xtourelle, ytourelle);
pos.x = xtourelle - rotation->w * 2; //ReTest du positionnement
pos.y = ytourelle - rotation->h * 2;
angle++;
}
SDL_FreeSurface(rotation);
}
} |
Partager