diff options
| -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); } |
