diff options
| author | esquizo <esquizo+noreply@esquizo.net> | 2026-05-17 12:21:44 -0300 |
|---|---|---|
| committer | esquizo <esquizo+noreply@esquizo.net> | 2026-05-17 12:22:15 -0300 |
| commit | ca457b3d0ed3dc6309e46633a2b467e3f9261753 (patch) | |
| tree | a362a1ac4ce80cfe28129a2153989396f0255d79 | |
| parent | b67f9b6b48715b325c3a2b3b5274467c778917a5 (diff) | |
libphysics: consertada a colisão com o tilemap
O tamanho do mapa não tava sendo configurado nas variáveis
| -rw-r--r-- | libphysics/_map.c | 3 | ||||
| -rw-r--r-- | libphysics/test/vis.c | 12 |
2 files changed, 13 insertions, 2 deletions
diff --git a/libphysics/_map.c b/libphysics/_map.c index 06d3cad..3057bf4 100644 --- a/libphysics/_map.c +++ b/libphysics/_map.c @@ -15,6 +15,9 @@ phxsetmap(int w, int h, int *tiles) if(phxmapbuffer) free(phxmapbuffer); + phxmapwidth = w; + phxmapheight = h; + phxmapbuffer = malloc(w * h * sizeof(phxmapbuffer[0])); memcpy(phxmapbuffer, tiles, sizeof(phxmapbuffer[0]) * w * h); } diff --git a/libphysics/test/vis.c b/libphysics/test/vis.c index d1f3f6f..7d6466a 100644 --- a/libphysics/test/vis.c +++ b/libphysics/test/vis.c @@ -61,7 +61,6 @@ main() 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, }); running = 1; @@ -107,6 +106,16 @@ render(void) SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF); SDL_RenderClear(renderer); + + SDL_SetRenderDrawColor(renderer, 0xFF, 0x00, 0xFF, 0xFF); + for(int y = 0; y < phxmapheight; y++) + for(int x = 0; x < phxmapwidth; x++) { + if(!phxmapbuffer[x + y * phxmapwidth]) + continue; + + renderrect((vec2){ x * 32, y * 32 }, (vec2){ 16, 16 }); + } + SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF); for(int i = 0; i < phxbodypoolsize; i++) { vec2 p, s; @@ -115,6 +124,5 @@ render(void) continue; renderrect(b->pos, b->size); } - SDL_RenderPresent(renderer); } |
