kettek2/wiki/games/newsboy/Newsboy_0x00/engine/Map.h

147 lines
3.3 KiB
C

#ifndef MAP_H
#define MAP_H
#include "Animation.h"
#include "game_globals.h"
// this looks like a job for...
#include "VoidMan.h"
#define CELL_BLOCKS_ENTITY 1
#define CELL_BLOCKS_PROJECTILE 2
#define CELL_BLOCKS_VISION 4
#define CELL_WALL 7
#define CYBERSPACE 0
#define MEATSPACE 1
struct PlayerMapData {
int x;
int y;
int frame;
char *anim;
char *set;
char *face;
};
struct MapData {
char *filename;
char *name;
char *session;
int location;
int width;
int height;
struct MapCell **cells;
struct PlayerMapData player_data;
int entity_count;
struct VoidMan *entities;
int trigger_count;
struct VoidMan *triggers;
int event_count;
struct VoidMan *events;
int path_count;
struct PathMapData **paths;
};
int initMapCells(struct MapData *map, int width, int height);
int freeMapCells(struct MapData *map);
int freeMapEntities(struct MapData *map);
int freeMapTriggers(struct MapData *map);
int freeMapEvents(struct MapData *map);
int freeMapPaths(struct MapData *map);
struct MapData *newMapData();
int freeMapData(struct MapData *map);
int saveMapData(struct MapData *map);
int loadMapData(struct MapData *map, const char *filename);
struct MapCell {
int flags;
int decor_count;
struct DecorMapData **decor;
};
int pushDecorMapData(struct MapCell *cell, struct DecorMapData *decor);
int popDecorMapData(struct MapCell *cell);
struct EntityMapData {
int x;
int y;
int w;
int h;
float radius;
struct Sprite *sprite; // temp ref sprite :)
char *name; // name of entity
char *set;
char *face;
int frame;
};
struct EntityMapData *newEntityMapData();
int freeEntityMapData(struct EntityMapData *entity);
int pushEntityMapData(struct MapData *map, struct EntityMapData *entity);
int delEntityMapData(struct MapData *map, int id);
struct DecorMapData {
int x;
int y;
int animated;
int frame;
struct Sprite *sprite; // temp ref sprite :)
char *anim;
char *set;
char *face;
};
struct DecorMapData *newDecorMapData();
int freeDecorMapData(struct DecorMapData *decor);
struct TriggerMapData {
int x;
int y;
int w;
int h;
int type;
int activator;
int behavior;
int iter; // iterations
int time;
int event_count;
char **events;
};
struct TriggerMapData *newTriggerMapData();
struct TriggerMapData *freeTriggerMapData(struct TriggerMapData *trigger);
int pushTriggerMapData(struct MapData *map, struct TriggerMapData *trigger);
int delTriggerMapData(struct MapData *map, int id);
struct EventMapData {
char *name;
int x;
int y;
int w;
int h;
int type;
int param_count;
int *param_type;
void **params;
};
struct EventMapData *newEventMapData();
struct EventMapData *freeEventMapData(struct EventMapData *event);
int pushEventMapData(struct MapData *map, struct EventMapData *event);
int delEventMapData(struct MapData *map, int id);
struct PathMapData {
int x;
int y;
int type;
struct PathMapNode *start;
};
struct PathMapNode {
int x;
int y;
int type;
struct PathMapNode *prev;
struct PathMapNode *left;
struct PathMapNode *right;
};
int setDefaultTravelMap(char *name);
int setCellFlags(struct MapData *map, int x, int y, int flags);
int setPlayer(struct MapData *map, int x, int y, const char *anim, const char *set, const char *face, int frame);
int initPlayer(struct MapData *map);
int freePlayer(struct MapData *map);
#endif