Draw player centered on position

This commit is contained in:
Camden Dixie O'Brien 2024-12-28 12:37:10 +00:00
parent 6ca053f126
commit e5752a5fe7

View File

@ -265,11 +265,11 @@ int main(int argc, char *argv[])
} }
// Draw player // Draw player
const unsigned piframe = (t / BASEANIMPERIOD) % PIANIMLEN; const unsigned piframe = (t / BASEANIMPERIOD) % PANIMLEN;
psrc.x = PIWIDTH * piframe; psrc.x = PWIDTH * piframe;
pdest.x = SCALE * (int)(ppos.x - vpos.x); pdest.x = SCALE * (int)(ppos.x - vpos.x - PWIDTH / 2);
pdest.y = SCALE * (int)(ppos.y - vpos.y); pdest.y = SCALE * (int)(ppos.y - vpos.y - PHEIGHT / 2);
SDL_RenderCopy(renderer, pitex, &psrc, &pdest); SDL_RenderCopy(renderer, pidle, &psrc, &pdest);
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
} }