aboutsummaryrefslogtreecommitdiff
path: root/gst/map.c
blob: 59d1ad142ae16340d7053d2a3ee4268be0742909 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdlib.h>
#include <stdio.h>
#include <units.h>
#include <string.h>

#include <map.h>

int ptoi (map *m, int *p) { return p[0]+p[1]*m->sx; }
int xytoi (map *m, int x, int y) { return x+y*m->sx; }

void map_init (map *m, int sx, int sy, int ts) {
    m->t = (int*)malloc(sizeof(int)*sx*sy);
    m->sx = sx; m->sy = sy; m->ts = ts;
    memset(m->t, 0, sizeof(int)*sx*sy);
}

void map_destroy (map *m) {
    free(m->t);
}