diff --git a/app/main.c b/app/main.c index f9efee5..a2699ec 100644 --- a/app/main.c +++ b/app/main.c @@ -117,6 +117,17 @@ static const unsigned impassable[] = { }; static objtype_t objtypes[MAXOBJTYPES]; static objcol_t objcol; +static entity_t p = { + .svar = SPRITE_DIR_DOWN, + .animlen = PANIMLEN, + .animstep = { .x = PWIDTH }, + .svarstep = { .y = PHEIGHT }, + .fbox = { + .off = { .x = PFBOFFX, .y = PFBOFFY }, + .ext = { .x = PFBWIDTH, .y = PFBHEIGHT }, + }, + .src = { .w = PWIDTH, .h = PHEIGHT }, +}; static inline double mag(dvec_t v) { @@ -459,7 +470,7 @@ int main(int argc, char *argv[]) tstex = IMG_LoadTexture(renderer, path); assert(NULL != tstex); - // Load player spritesheets + // Load player spritesheets and initialize texture assert(strlen(assetdir) + strlen(PIDLE_ASSET) < MAX_PATH_LEN); strcpy(path, assetdir); strcat(path, PIDLE_ASSET); @@ -470,20 +481,7 @@ int main(int argc, char *argv[]) strcat(path, PWALK_ASSET); pwalk = IMG_LoadTexture(renderer, path); assert(NULL != pwalk); - - // Initialize player - entity_t p = { - .svar = SPRITE_DIR_DOWN, - .animlen = PANIMLEN, - .tex = pidle, - .animstep = { .x = PWIDTH }, - .svarstep = { .y = PHEIGHT }, - .fbox = { - .off = { .x = PFBOFFX, .y = PFBOFFY }, - .ext = { .x = PFBWIDTH, .y = PFBHEIGHT }, - }, - .src = { .w = PWIDTH, .h = PHEIGHT }, - }; + p.tex = pidle; bool f = true; SDL_SetRenderDrawColor(renderer, 0xff, 0x00, 0x00, 0xff);