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 36 37 38 39 40 41 42
|
//------------------------------------------------------------------------------
//---- Chargement de la map ----------------------------------------------------
//------------------------------------------------------------------------------
void affichageMap(SDL_Surface *ecran, SDL_Surface *background, FILE* map, SDL_Surface *spriteChoisi[])
{
//---- Déclaration des variables -----------------------------------------------
SDL_Rect position, partieRestante;
int choixSprite = 0;
//------------------------------------------------------------------------------
//---- Affichage du Background -------------------------------------------------
SDL_BlitSurface(background, NULL, ecran, NULL);
//------------------------------------------------------------------------------
//---- On lit le contenu du fichier & on affiche les sprites -------------------
if(map != NULL)
{
while(!feof(map))
{
//---- On lit le fichier sprite, abscisse , ordonnée--------------------
fscanf(map,"%ld %ld %ld %ld %ld %ld %ld\n", &choixSprite, &position.x, &position.y, &partieRestante.w, &partieRestante.h, &partieRestante.x, &partieRestante.y);
//----------------------------------------------------------------------
//---- On affiche le sprite correspondant ------------------------------
SDL_BlitSurface(spriteChoisi[choixSprite], &partieRestante, ecran, &position);
//----------------------------------------------------------------------
}
SDL_Flip(ecran);
}
//------------------------------------------------------------------------------
//---- Fermeture du fichier ----------------------------------------------------
fclose(map);
//------------------------------------------------------------------------------
} |
Partager