summaryrefslogtreecommitdiff
path: root/src/xd.h
blob: 163c6806144b6b7b3101382157d7bf846110450e (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
64
65
66
67
68
69
70
71
72
#ifndef __XD_H__
#define __XD_H__

#define XD_VERSION 1
#define XD_MAX_ENTITIES 256
#define XD_MAX_TEXTURES 256

typedef enum { PLAYER_START = 0, NEXT_FLOOR, PREVIOUS_FLOOR } XdEntityType;
typedef enum { TILE_FLOOR = 0, TILE_WALL, TILE_CORNER } XdTileType;

typedef struct {
    char *type;
    unsigned char *data;
    int width, height, dataSize;
} XdTexture;

typedef struct {
    XdTexture *texture;
    int id;
    XdTileType type;
} XdTile;

typedef struct {
    int id;
    XdTileType type;
} XdTileData;

typedef struct {
    int x, y;
    XdTexture *texture;
} XdMapTile;

typedef struct {
    int id;
    XdTexture *texture;
    XdEntityType type;
} XdEntity;

typedef struct {
    int x, y;
    XdEntity *entity;
} XdMapEntity;

typedef struct {
    int zIndex;
    XdMapEntity *entities[XD_MAX_ENTITIES];
    XdMapTile *tiles[];
} XdMapLayer;

typedef struct {
    int width, height;
    XdMapLayer *layers[];
} XdFloor;

typedef struct {
    int id;
    XdFloor *floors[];
} XdLevel;

typedef struct {
    char *name;
    int version;
    XdTexture *textures[XD_MAX_TEXTURES];
    XdTile *tiles[XD_MAX_TEXTURES];
    XdEntity *entities[XD_MAX_ENTITIES];
    XdLevel *levels[];
} XdData;

XdData Xd_LoadFromFile(const char *filePath);
void Xd_SaveFile(const char *filePath, XdData *xd);

#endif