aboutsummaryrefslogtreecommitdiff
path: root/src/tiles.c
blob: b09ca9563f60c089c458e1c5a4e6d5adebd580ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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');
    }
}