NXEngine v1.0.0.6
[NXEngine.git] / map.h
blobf26f163721e14f473989db9773dbd19746e5aee9
2 #ifndef _MAP_H
3 #define _MAP_H
5 #define MAX_MOTION_TILES 20
7 #define MAP_MAXSIZEX 300
8 #define MAP_MAXSIZEY 256
10 #define MAP_PHASE_ADJ_SPEED 64
12 // this macro returns true if the current stage is spec'd to use the specified NPC spriteset.
13 #define DoesCurrentStageUseSpriteset(SET) \
14 ( stages[game.curmap].NPCset1==SET || stages[game.curmap].NPCset2==SET )
16 #define MAPX(X) ( ( (X) * TILE_W ) << CSF )
17 #define MAPY(Y) ( ( (Y) * TILE_H ) << CSF )
19 struct stMap
21 int xsize, ysize;
22 int displayed_xscroll, displayed_yscroll;
23 int maxxscroll, maxyscroll;
24 int parscroll_x, parscroll_y;
26 int real_xscroll, real_yscroll;
27 int phase_adj;
29 int target_x, target_y;
31 int scrollcenter_x, scrollcenter_y;
32 int scrollspeed;
33 bool scroll_locked;
36 uint8_t backdrop; // backdrop # in use
37 int scrolltype; // backdrop scroll type
39 Object *waterlevelobject; // object controlling water level (for maps with rising water)
40 int wlforcestate; // set by Core--modifies the state of the water level object
41 int wlstate; // set by WaterLevel object--reports it's current state
43 // for FON, FOM script commands
44 struct
46 Object *target;
47 bool has_target;
48 } focus;
50 // motion tiles used in Waterway and Main Artery--these tiles use
51 // a sprite as their image data and pan the sprite across them in a specified direction
52 struct
54 int tileno; // tile # to animate
55 uchar dir; // direction of scrolling
56 int sprite; // sprite # containing image data
57 } motiontiles[MAX_MOTION_TILES];
58 int nmotiontiles;
59 int motionpos;
61 unsigned char tiles[MAP_MAXSIZEX][MAP_MAXSIZEY];
64 extern stMap map;
66 void map_focus(Object *o, int spd = 16);
68 // background scrolling types
69 #define BK_FIXED 0 // backdrop does not scroll
70 #define BK_PARALLAX 1 // bk is parallax scroll
71 #define BK_FOLLOWFG 2 // scrolls, but is 1:1 with foreground
72 #define BK_HIDE 3 // draw #000021 blue instead of a graphic
73 #define BK_HIDE2 4 // identical to BK_HIDE
74 #define BK_FASTLEFT 5 // fast scroll left, items falling left (ironhead battle)
75 #define BK_FASTLEFT_LAYERS 6 // fast scroll left w/ layers, items falling left (Outer Wall)
76 #define BK_FASTLEFT_LAYERS_NOFALLLEFT 7 // fast left w/ layers, but items don't fall left (Balcony)
77 #define BK_HIDE3 8 // identical to BK_HIDE
79 #define MAX_TILES 256 // max # of different kinds of tiles per tileset
81 // these flag constants come from the stage data somewhere I believe
82 // (don't remember for sure) so they should stay constant.
83 #define TA_SOLID_PLAYER 0x00001 // solid to player
84 #define TA_SOLID_NPC 0x00002 // solid to npc's, enemies and enemy shots
85 #define TA_SOLID_SHOT 0x00004 // solid to player's shots
86 #define TA_SOLID (TA_SOLID_PLAYER | TA_SOLID_SHOT | TA_SOLID_NPC)
87 #define TA_HURTS_PLAYER 0x00010 // this tile hurts the player -10hp
88 #define TA_FOREGROUND 0x00020 // tile is drawn in front of sprites
89 #define TA_DESTROYABLE 0x00040 // tile is destroyable if player shoots it
90 #define TA_WATER 0x00080 // tile is water/underwater
92 #define TA_CURRENT 0x00100 // blows player (tilecode checked to see which direction)
93 #define TA_SLOPE 0x00200 // is a slope (the tilecode is checked to see what kind)
95 extern uint8_t tilecode[MAX_TILES];
96 extern uint32_t tileattr[MAX_TILES];
97 extern uint32_t tilekey[256];
98 extern Object *ID2Lookup[65536];
100 void AnimateMotionTiles(void);
102 void map_ChangeTileWithSmoke(int x, int y, int newtile, int nclouds=4, bool boomflash=false, Object *push_behind=NULL);
104 // map names and info from stage.dat
105 #include "maprecord.h"
107 // backdrop and tileset names
108 #include "stagedata.h"
110 // needed if resolution is changed to a non-multiple of the tile size
111 #if (((SCREEN_WIDTH / TILE_W) * TILE_W) != SCREEN_WIDTH)
112 #define MAP_DRAW_EXTRA_X 1
113 #else
114 #define MAP_DRAW_EXTRA_X 0
115 #endif
117 #if (((SCREEN_HEIGHT / TILE_H) * TILE_H) != SCREEN_HEIGHT)
118 #define MAP_DRAW_EXTRA_Y 1
119 #else
120 #define MAP_DRAW_EXTRA_Y 0
121 #endif
123 #endif