[SDL] SDL_Surface & malloc

Marcos markken at iespana.es
Sat Feb 22 17:11:01 PST 2003


Two times? Sorry.
----- Original Message -----
From: "Marcos" <markken at iespana.es>
To: <sdl at libsdl.org>
Sent: Sunday, February 23, 2003 12:28 AM
Subject: [SDL] SDL_Surface & malloc


> 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--------------------------------------------------------
> Únete a los miles de sin pareja en Meetic... ¡te vas a enamorar!
> http://www.iespana.es/_reloc/email.meetic
>
>
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
>
> ---Publicidad--------------------------------------------------------
> Únete a los miles de sin pareja en Meetic... ¡te vas a enamorar!
> http://www.iespana.es/_reloc/email.meetic


---Publicidad--------------------------------------------------------
Únete a los miles de sin pareja en Meetic... ¡te vas a enamorar!
http://www.iespana.es/_reloc/email.meetic





More information about the SDL mailing list