diff options
Diffstat (limited to 'src/tiles.c')
-rw-r--r-- | src/tiles.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/tiles.c b/src/tiles.c new file mode 100644 index 0000000..b09ca95 --- /dev/null +++ b/src/tiles.c @@ -0,0 +1,39 @@ +#include <stdio.h> +#include "ppm.h" + +extern int *(tiles[]); +extern int TILE_WIDTH; +extern int TILE_HEIGHT; + +void load_tiles(int n) +{ + int width, height; + for(int i = 0; i < n; i++) + { + char file_path[26]; + sprintf(file_path, "files/tile_%d.ppm", i); + tiles[i] = load_from_ppm(file_path, &width, &height); + } + TILE_WIDTH = width; + TILE_HEIGHT = height; +} + +void free_tiles(int n) +{ + for(int i = 0; i < n; i++) + free_ppm(tiles[i]); +} + +void print_tiles(int n) +{ + for(int i = 0; i < n; i++) + { + for(int y = 0; y < TILE_HEIGHT; y++) + { + for(int x = 0; x < TILE_WIDTH; x++) + putchar(tiles[i][y * TILE_WIDTH + x] + '0'); + putchar('\n'); + } + putchar('\n'); + } +} |