Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int MapFlags[214747];
- int MapData[214747];
- int MapDMaps[214747];
- int MapScreens[214747];
- const int MAP_FLAG_BLANK = 000000000000b;
- const int MAP_FLAG_ROOM = 000000000001b;
- const int MAP_FLAG_VISITED = 000000000010b;
- const int MAP_FLAG_ITEM = 000000000100b;
- const int MAP_FLAG_CHEST = 000000001000b;
- const int MAP_FLAG_KEY = 000000010000b;
- const int MAP_FLAG_BOSSKEY = 000000100000b;
- const int MAP_FLAG_BOSSCHEST = 000001000000b;
- const int MAP_FLAG_SAVE = 000010000000b;
- const int MAP_FLAG_BOSS = 000100000000b;
- const int MAP_FLAG_MIDBOSS = 001000000000b;
- const int MAP_FLAG_TRIFORCE = 010000000000b;
- void SetMapFlag(int index, int flag, bool state){
- if ( state ) MapFlags[index] |= flag;
- else MapFlags[index] &= ~flag;
- }
- void GetMapFlag(int index, int flag){
- return ( MapFlags[index]&flag ) != 0;
- }
- //An arbitrary way to find the index for a specific screen and dmap.
- //We probably do not want to go tis route, and we'll use dmap sizing to stitch them together, then hardcode
- //their attributes so that we know what each index is.
- //
- //We can set constant floats for each room if desired, but this is certainly the lazy approach.
- int GetRoom(int dmap, int screen){
- int scr; int dmp; int q; int w; int index;
- for ( q = 0; q < SizeOfArray(MapDMaps); q++ ) {
- if ( MapDMaps[q] == dmap && MapScreens[q] == screen ) return q;
- }
- return -1;
- }
- //We draw 8x8 tiles for eacdh map space. These may be black (blank), grey (room), or blue (visited room).
- //We use the flags for each index to draw the rooms.
- const int MAP_TILE_EMPTYSPACE = 1000;
- const int MAP_TILE_ROOM = 1001;
- const int MAP_TILE_ROOMVISITED = 1002;
- const int MAP_ICON_ROOMITEM = 1003; //Overlay = icon
- const int MAP_ICON_ROOMSAVE = 1004;
- const int MAP_ICON_BOSS = 1005;
- const int MAP_OVERALL_WIDTH_COLUMNS = 500;
- const int MAP_OVERALL_HEIGHT_ROWS = 100;
- void DrawMapRoomsToBitmap(){
- int q; int w; int x; int y;
- for ( q = 0; q < SizeOfArray(MapFlags); q++ ) {
- //Draw those rows
- if ( q > 0 && q % MAP_OVERALL_WIDTH_COLUMNS == 0 ) { y += MAP_ROOM_Y; x = 0; } //New line
- //Draw the rooms and scale them.
- if ( GetMapFlag(q, MAP_FLAG_BLANK) ) DrawTile(q, MAP_TILE_EMPTYSPACE, MAP_TILE_WIDTH, MAP_TILE_HEIGHT);
- if ( GetMapFlag(q, MAP_FLAG_ROOM) && !GetMapFlag(q, MAP_FLAG_VISITED) ) DrawTile(q, MAP_TILE_ROOM, MAP_TILE_WIDTH, MAP_TILE_HEIGHT);
- if ( GetMapFlag(q, MAP_FLAG_ROOM) && GetMapFlag(q, MAP_FLAG_VISITED) ) DrawTile(q, MAP_TILE_VISITED, MAP_TILE_WIDTH, MAP_TILE_HEIGHT);
- //Draw any room icons
- if ( GetMapFlag(q, MAP_FLAG_BOSS) ) DrawTile(q, MAP_ICON_BOSS, MAP_TILE_WIDTH, MAP_TILE_HEIGHT);
- if ( GetMapFlag(q, MAP_FLAG_ITEM) ) DrawTile(q, MAP_ICON_ROOMITEM, MAP_TILE_WIDTH, MAP_TILE_HEIGHT);
- if ( GetMapFlag(q, MAP_FLAG_SAVE) ) DrawTile(q, MAP_ICON_ROOMSAVE, MAP_TILE_WIDTH, MAP_TILE_HEIGHT);
- //Next room
- x += MAP_ROOM_X;
- }
- }
- const int MAP_TILE_WIDTH = 8;
- const int MAP_ROOM_X = 10;
- const int MAP_ROOM_Y = 10;
- const int MAP_ROOM_CENTER = 2;
- //We draw rooms in a pseudo-grid. Each room is a tile, drawn every ROOM_X pixels, in a row.
- //Each row is drawn ROOM_Y pixels below the previosu row, to the bitmap.
- const int MAP_BITMAP = 4;
- const int MAP_SLICE_X = 200; //20 rooms.
- const int MAP_SLICE_Y = 120; //12 rooms.
- void FindMapCentre(){} //Find the centre of the map based on the present room.
- const int MAP_DRAW_OFFSET_X = 100; //Half the size of the map, from the centre.
- const int MAP_DRAW_OFFSET_Y = 60; //Half the size of the map, from the centre.
- void MapToScreen(){
- // We draw the map from the bitmap, on layer 7. To accomplish this, we find its centre, and draw the
- // upper-left corner based on the true centre ( FindMapCentre() - OFFSETS), minus the offsets,
- // and set the full width and height to its size (MAP_SLICE).
- Screen->DrawBitmap(MAP_DRAW_LAYER, MAP_BITMAP, (FindMapCentre() - MAP_DRAW_OFFSET_X), (FindMapCentre() - MAP_DRAW_OFFSET_Y), MAP_SLICE_X, MAP_SLICE_Y, true);
- }
- const int MAP_DRAW_LAYER = 7;
- const int MAP_DRAW_X = 4; //Upper-left corner of map display.
- const int MAP_DRAW_Y = 4;
- //Dmaps
- //If we predefine the exact width and height of each dmap, we can stitch them together.
- const int DMAP_WIDTH_1 = 16; //16 rooma
- const int DMAP_HEIGHT_1 = 8; //8 rooms
- const int DMAP_WIDTH_1 = 8; //8 rooma
- const int DMAP_HEIGHT_1 = 8; //8 rooms
- //...
- ///...then we define the placement of the dmap in the overall map.
- const int FIRST_ROW_DMAP_1 = 0;
- const int FIRST_COLUMN_DMAP_1 = 0;
- const int LAST_COLUMN_DMAP_1 = 15;
- const int LAST_ROW_DMAP_1 = 7;
- const int FIRST_ROW_DMAP_2 = 0;
- const int FIRST_COLUMN_DMAP_2 = 16; //This dmap would be stitched to the exact right of dmap 1
- const int LAST_COLUMN_DMAP_1 = 23; //This would be an 8x8 DMAp attached to a 16x8 DMAP.
- const int LAST_ROW_DMAP_1 = 7;
- void DoMap(){
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement