so I'm working on a code for filling a screen with a table of surfaces; here's the code:
main.c
#ifdef __cplusplus
#include <cstdlib>
#else
#include <stdlib.h>
#endif
#include <SDL/SDL.h>
#include <SDL_image.h>
#include "maploader.h"
#define W 510
#define H 510
#define SIZE 34
void pause();
int main ( int argc, char** argv )
{
SDL_Surface *screen = NULL;
SDL_Surface *surfaces[15][15];
SDL_Init(SDL_INIT_VIDEO);
screen = SDL_SetVideoMode(W, H, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
SDL_WM_SetCaption("demon game", NULL);
SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 255, 255, 255));
mapload(screen, surfaces[15][15], NULL);
SDL_Flip(screen);
pause();
SDL_QUIT;
return EXIT_SUCCESS;
}
void pause()
{
int continuer = 1;
SDL_Event event;
while (continuer)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
continuer = 0;
}
}
}
maploader.c
#ifdef __cplusplus
#include <cstdlib>
#else
#include <stdlib.h>
#endif
#include <SDL/SDL.h>
#include <SDL_image.h>
#define W 510
#define H 510
#define SIZE 34
SDL_Surface *surfaces[15][15];
void mapload(SDL_Surface *screen, SDL_Surface *surfaces[][15], int lvl)
{
FILE *level = NULL;
char elements[125];
int i, j, k = 0;
SDL_Rect elementposition = {0,0};
level = fopen("level.txt", "r");
if (level == NULL)
{
exit(0);
}
fgets(elements, 125, level);
SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 255, 255, 255));
for (i=0; i<15; i++)
{
for (j=0; j<15; j++)
{
if (elements[k] == "0")
{
surfaces[i][j] = IMG_Load("mur.jpg");
}
else if (elements[k] == "1")
{
surfaces[i][j] = IMG_Load("caisse.jpg");
}
else if (elements[k] == "2")
{
surfaces[i][j] = IMG_Load("objectif.png");
}
else
{
surfaces[i][j] = NULL;
}
k++;
}
}
for (i=0; i<15; i++)
{
for (j=0; j<15; j++)
{
SDL_BlitSurface(surfaces[i][j], NULL, screen, &elementposition);
elementposition.x += SIZE;
}
elementposition.y += SIZE;
}
}
the only error I get from compiling is the following: "cannot convert 'SDL_Surface*' to 'SDL_Surface* ()[15]' for argument '2' to 'void mapload(SDL_Surface, SDL_Surface* (*)[15], int)'|"
apparently, the error is initialized from the second argument of the mapload function, but I don't have a clear idea about what exactly is wrong. any ideas, please?