Store asset dir path in static var
This commit is contained in:
parent
dab37ddeff
commit
12751a49f8
18
app/main.c
18
app/main.c
@ -85,6 +85,7 @@ typedef struct {
|
||||
SDL_Rect src;
|
||||
} entity_t;
|
||||
|
||||
static const char *assetdir;
|
||||
static SDL_Window *window;
|
||||
static SDL_Renderer *renderer;
|
||||
static unsigned map[MAPNLAYERS][MAPWIDTH][MAPHEIGHT];
|
||||
@ -294,6 +295,7 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "Usage: %s ASSETS-DIR\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
assetdir = argv[1];
|
||||
|
||||
// Set up SDL window
|
||||
int err = SDL_Init(SDL_INIT_VIDEO);
|
||||
@ -306,26 +308,26 @@ int main(int argc, char *argv[])
|
||||
assert(NULL != renderer);
|
||||
|
||||
// Load map
|
||||
assert(strlen(argv[1]) + strlen(MAP_ASSET) < MAX_PATH_LEN);
|
||||
strcpy(path, argv[1]);
|
||||
assert(strlen(assetdir) + strlen(MAP_ASSET) < MAX_PATH_LEN);
|
||||
strcpy(path, assetdir);
|
||||
strcat(path, MAP_ASSET);
|
||||
mapload(path);
|
||||
|
||||
// Load tileset
|
||||
assert(strlen(argv[1]) + strlen(TSASSET) < MAX_PATH_LEN);
|
||||
strcpy(path, argv[1]);
|
||||
assert(strlen(assetdir) + strlen(TSASSET) < MAX_PATH_LEN);
|
||||
strcpy(path, assetdir);
|
||||
strcat(path, TSASSET);
|
||||
tstex = IMG_LoadTexture(renderer, path);
|
||||
assert(NULL != tstex);
|
||||
|
||||
// Load player spritesheets
|
||||
assert(strlen(argv[1]) + strlen(PIDLE_ASSET) < MAX_PATH_LEN);
|
||||
strcpy(path, argv[1]);
|
||||
assert(strlen(assetdir) + strlen(PIDLE_ASSET) < MAX_PATH_LEN);
|
||||
strcpy(path, assetdir);
|
||||
strcat(path, PIDLE_ASSET);
|
||||
pidle = IMG_LoadTexture(renderer, path);
|
||||
assert(NULL != pidle);
|
||||
assert(strlen(argv[1]) + strlen(PWALK_ASSET) < MAX_PATH_LEN);
|
||||
strcpy(path, argv[1]);
|
||||
assert(strlen(assetdir) + strlen(PWALK_ASSET) < MAX_PATH_LEN);
|
||||
strcpy(path, assetdir);
|
||||
strcat(path, PWALK_ASSET);
|
||||
pwalk = IMG_LoadTexture(renderer, path);
|
||||
assert(NULL != pwalk);
|
||||
|
Loading…
x
Reference in New Issue
Block a user