Marcos Prieto Gonzalez
2003-02-22 22:12:48 UTC
Hi, i´m triying to develop a tile system for a game. I start with a
example program that display some random tiles on the screen. I don´t
know if use a surface for each tile is the corret way...
I have a compiler error here ( i ´m a C newbie)
//Declarations
SDL_Surface *tiles, *screen;
...
//Dinamic Memory for the array of surfaces
n_tiles = 4;
tiles = (SDL_Surface *) malloc (n_tiles * sizeof(SDL_Surface));
if(tiles == NULL){ printf("Error de memoria\n"); return -1; }
...
//Images load
for(i = 0; i <= n_tiles; i++){
sprintf(ruta,"%s%d%s","tiles",i,".png");
printf("%s", ruta);
tiles[i] = SDL_LoadBMP(ruta); /*In this line the compiler says
uncompatible types assignament, with &tiles[i] = ... i have an error
too.*/
if(&tiles[i]==NULL) printf("Error al abrir una imagen\n");
}
what ´s the problem? Thanks.
(Sorry for my english, i hope you can understand me)
---Publicidad--------------------------------------------------------
Juega con Ventura24.es, lotería inteligente y multiplica tus
posibilidades!! http://www.iespana.es/_reloc/email.ventura
example program that display some random tiles on the screen. I don´t
know if use a surface for each tile is the corret way...
I have a compiler error here ( i ´m a C newbie)
//Declarations
SDL_Surface *tiles, *screen;
...
//Dinamic Memory for the array of surfaces
n_tiles = 4;
tiles = (SDL_Surface *) malloc (n_tiles * sizeof(SDL_Surface));
if(tiles == NULL){ printf("Error de memoria\n"); return -1; }
...
//Images load
for(i = 0; i <= n_tiles; i++){
sprintf(ruta,"%s%d%s","tiles",i,".png");
printf("%s", ruta);
tiles[i] = SDL_LoadBMP(ruta); /*In this line the compiler says
uncompatible types assignament, with &tiles[i] = ... i have an error
too.*/
if(&tiles[i]==NULL) printf("Error al abrir una imagen\n");
}
what ´s the problem? Thanks.
(Sorry for my english, i hope you can understand me)
---Publicidad--------------------------------------------------------
Juega con Ventura24.es, lotería inteligente y multiplica tus
posibilidades!! http://www.iespana.es/_reloc/email.ventura