Adoranda/include/map.h

59 lines
1.3 KiB
C
Raw Normal View History

2021-07-29 18:33:22 +02:00
#pragma once
#include <gint/display.h>
2021-08-25 01:01:43 +02:00
#include "engine.h"
2022-01-18 23:43:48 +01:00
struct Teleporter {
int x, y;
int idMap;
int x2, y2;
};
2022-02-17 00:02:00 +01:00
struct Zone {
int start_x, start_y;
int end_x, end_y;
int level;
2022-02-19 01:21:38 +01:00
int nbMonsters;
short *monsters;
2022-02-17 00:02:00 +01:00
};
2021-08-15 03:46:49 +02:00
struct Map {
2022-01-18 23:43:48 +01:00
/*width, height and the number of layer of the map*/
2022-02-17 00:02:00 +01:00
int w, h, nb_layers, dialog_count, teleporter_count, zone_count;
2021-08-08 01:43:26 +02:00
/*the tileset to use*/
2021-07-29 18:33:22 +02:00
bopti_image_t *tileset;
2022-01-22 17:12:24 +01:00
int tileset_size;
/*list of all the dialog*/
struct Talkable *dialogs;
2022-01-18 23:43:48 +01:00
struct Teleporter *teleporters;
2022-02-17 00:02:00 +01:00
struct Zone *zones;
2021-08-08 01:43:26 +02:00
/*state of each tile on the map (solid, air ...)*/
short *info_map;
/*list of all the tiles*/
short *layers[];
2021-07-29 18:33:22 +02:00
};
enum map_state {
2022-02-17 21:26:33 +01:00
TILE_AIR,
TILE_SOLID,
TILE_DOOR_IN,
TILE_DOOR_OUT,
TILE_TALKABLE,
TILE_TELEPORTER,
TILE_GRASS,
2021-07-29 18:33:22 +02:00
};
2021-08-15 03:10:05 +02:00
/*check if a tile is walkable*/
2021-08-15 03:46:49 +02:00
int map_walkable(struct Map const *map, int x, int y);
2021-08-15 03:10:05 +02:00
/*get the tile under the player*/
2021-08-15 03:46:49 +02:00
int map_get_player_tile(struct Game const *game);
2021-08-27 22:50:00 +02:00
void generate_interior_map(struct Game *game);
void set_map(struct Game *game, int id);
2022-01-18 23:43:48 +01:00
struct Vec2 locate_tile(struct Map const *map, int tile);
2022-02-17 00:02:00 +01:00
struct Teleporter get_teleporter_xy(struct Map *map, struct Vec2 pos);
2022-02-19 01:21:38 +01:00
int is_in_zone(struct Player *player, struct Map *map);
struct Zone get_zone(struct Player *player, struct Map *map);