#ifndef TILE_H #define TILE_H #define TILE_NULL 0 #define PASS 0 #define NO_PASS 1 #define NULL_CHAR '\0' #define PLAYER 1 #define FLOOR 2 #define WALL 3 #define DOOR 4 #define ITEM 5 #define NPC 6 #define STATE_CLOSED 0 #define STATE_OPEN 1 #define STATE_BROKEN 2 #define STATE_MISSING 3 /*** Tile struct Tile is the overarching struct for all objects on the map, be they walls, items, monsters, or even the players. ***/ struct Tile { unsigned int tid; short id; // the tile's id, 0-9,999=walls;10,000-19,999=ground;20,000-29,999=items;30,000-39,999=monsters short x; // x coords on the map short y; // y coords on the map struct Tile *next; // pointer to next Tile in the chain struct Tile *prev; // pointer to previous Tile in the chain void *data; // pointer to the Tile's actual data, preferably a struct }; struct Tile null_tile; // FIXME: temporary solution to next and prev pointers struct BasicTile { int collision; char name[16]; }; struct DoorTile { int collision; char name[16]; int state; }; extern struct DoorTile doors[]; struct PlayerTile { int collision; char name[16]; int vision; struct Controller *controller; }; extern struct PlayerTile players[]; struct NpcTile { int collision; char name[16]; struct Tile *target; int behavior; // for BEHAVE_AGGRESSIVE, etc. int vision; }; extern struct NpcTile npcs[]; /* interface used for creating new Tile */ struct Tile *newTile(unsigned int tid, short id, short x, short y); void freeTile(struct Tile* tile); /* */ /*** activateTile (target_tile, activator_tile) This function, when called on a TRIGGER tile, attempts to do various operations on the target_tile depending on the TriggerTile's type among other conditions. A basic example is the DOOR subtype, which simple toggles from STATE_OPEN to STATE_CLOSED and vice versa when activated. ***/ int activateTile(struct Tile *target_tile, struct Tile *activator_tile); #endif