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

#include "units.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);
}