Move player entity into static

This commit is contained in:
Camden Dixie O'Brien 2025-01-02 00:18:25 +00:00
parent f196440112
commit c02068f1ba

View File

@ -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);