summaryrefslogtreecommitdiff
path: root/src/map.c
blob: 61b272e4ecdcbe7cce950b38729cbdd91b31fbe0 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "map.h"
#include "cfg.h"
#include "../map/maps.h"
#include <stddef.h>

static unsigned int map_id = 0;

void
map_next(void)
{
	if (tmj2c_maps[map_id + 1] != NULL)
		map_id += 1;
}

void
map_previous(void)
{
	if (map_id > 0)
		map_id -= 1;
}

int
map_width(void)
{
	return tmj2c_maps[map_id]->width;
}

int
map_height(void)
{
	return tmj2c_maps[map_id]->height;
}

int
map_get(int x, int y)
{
	if (x < 0 || y < 0 || x >= map_width() || y >= map_height())
		return 1;
	if (tmj2c_maps[map_id]->numlayers < 1)
		return 1;
	return tmj2c_maps[map_id]->layers[0].data[x + y * map_width()];
}

int
map_get_px(int x, int y)
{
	if (x < 0 || y < 0)
		return 1;
	return map_get(x / TSIZE, y / TSIZE);
}

void
map_draw(void)
{
}

const Tmj2cObject *
map_objects(unsigned int *size)
{
	if (size != NULL)
		*size = tmj2c_maps[map_id]->numobjects;
	return tmj2c_maps[map_id]->objects;
}