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;
|
SDL_Rect src;
|
||||||
} entity_t;
|
} entity_t;
|
||||||
|
|
||||||
|
static const char *assetdir;
|
||||||
static SDL_Window *window;
|
static SDL_Window *window;
|
||||||
static SDL_Renderer *renderer;
|
static SDL_Renderer *renderer;
|
||||||
static unsigned map[MAPNLAYERS][MAPWIDTH][MAPHEIGHT];
|
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]);
|
fprintf(stderr, "Usage: %s ASSETS-DIR\n", argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
assetdir = argv[1];
|
||||||
|
|
||||||
// Set up SDL window
|
// Set up SDL window
|
||||||
int err = SDL_Init(SDL_INIT_VIDEO);
|
int err = SDL_Init(SDL_INIT_VIDEO);
|
||||||
@ -306,26 +308,26 @@ int main(int argc, char *argv[])
|
|||||||
assert(NULL != renderer);
|
assert(NULL != renderer);
|
||||||
|
|
||||||
// Load map
|
// Load map
|
||||||
assert(strlen(argv[1]) + strlen(MAP_ASSET) < MAX_PATH_LEN);
|
assert(strlen(assetdir) + strlen(MAP_ASSET) < MAX_PATH_LEN);
|
||||||
strcpy(path, argv[1]);
|
strcpy(path, assetdir);
|
||||||
strcat(path, MAP_ASSET);
|
strcat(path, MAP_ASSET);
|
||||||
mapload(path);
|
mapload(path);
|
||||||
|
|
||||||
// Load tileset
|
// Load tileset
|
||||||
assert(strlen(argv[1]) + strlen(TSASSET) < MAX_PATH_LEN);
|
assert(strlen(assetdir) + strlen(TSASSET) < MAX_PATH_LEN);
|
||||||
strcpy(path, argv[1]);
|
strcpy(path, assetdir);
|
||||||
strcat(path, TSASSET);
|
strcat(path, TSASSET);
|
||||||
tstex = IMG_LoadTexture(renderer, path);
|
tstex = IMG_LoadTexture(renderer, path);
|
||||||
assert(NULL != tstex);
|
assert(NULL != tstex);
|
||||||
|
|
||||||
// Load player spritesheets
|
// Load player spritesheets
|
||||||
assert(strlen(argv[1]) + strlen(PIDLE_ASSET) < MAX_PATH_LEN);
|
assert(strlen(assetdir) + strlen(PIDLE_ASSET) < MAX_PATH_LEN);
|
||||||
strcpy(path, argv[1]);
|
strcpy(path, assetdir);
|
||||||
strcat(path, PIDLE_ASSET);
|
strcat(path, PIDLE_ASSET);
|
||||||
pidle = IMG_LoadTexture(renderer, path);
|
pidle = IMG_LoadTexture(renderer, path);
|
||||||
assert(NULL != pidle);
|
assert(NULL != pidle);
|
||||||
assert(strlen(argv[1]) + strlen(PWALK_ASSET) < MAX_PATH_LEN);
|
assert(strlen(assetdir) + strlen(PWALK_ASSET) < MAX_PATH_LEN);
|
||||||
strcpy(path, argv[1]);
|
strcpy(path, assetdir);
|
||||||
strcat(path, PWALK_ASSET);
|
strcat(path, PWALK_ASSET);
|
||||||
pwalk = IMG_LoadTexture(renderer, path);
|
pwalk = IMG_LoadTexture(renderer, path);
|
||||||
assert(NULL != pwalk);
|
assert(NULL != pwalk);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user