summaryrefslogtreecommitdiffstats
path: root/src/resources/map.h
blob: 11ba8084251e61a25bc015b328fd82f06d1c2cb8 (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
#ifndef RESOURCE_MAP_H
#define RESOURCE_MAP_H

#include <SDL_stdinc.h>
#include "resource.h"
#include "image.h"

enum layer_id {
	LAYER_GROUND = 0,
	LAYER_OBJ_LOW,
	LAYER_CHAR_BOT,
	LAYER_OBJ_MID,
	LAYER_CHAR_TOP,
	LAYER_OBJ_HIGH,
	LAYER_WEATHER,
	LAYERS_MAX
};
struct tileset {
	struct resource res;
	char *dirname;
	char *name;
	int tilewidth;
	int tileheight;
	struct image *image;
};
struct map_tileset {
	struct tileset *tileset;
	int firstgid;
	struct map_tileset *next;
};
struct layer {
	struct map *map;
	Uint32 *tiles;
	char *encoding;
	char *compression;
	char *raw_data;
};
struct map {
	struct resource res;
	char *dirname;
	int width;
	int height;
	int tilewidth;
	int tileheight;
	struct map_tileset *tilesets_head;
	struct map_tileset *tilesets_tail;
	struct layer layers[LAYERS_MAX];
	Uint8 *collision;
	int cur_ts_firstgid;
};

struct map *map_get(const char *path);
void map_free(struct map *map);
void map_add_tileset(struct map *m, struct tileset *t, int firstgid);
struct layer *map_get_layer(struct map *m, const char *name);

#endif