Advertisement
ZoriaRPG

ywkls_map.zs v0.1

Oct 14th, 2016
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.78 KB | None | 0 0
  1. int MapFlags[214747];
  2. int MapData[214747];
  3. int MapDMaps[214747];
  4. int MapScreens[214747];
  5.  
  6. const int MAP_FLAG_BLANK    =   000000000000b;
  7. const int MAP_FLAG_ROOM     =   000000000001b;
  8. const int MAP_FLAG_VISITED  =   000000000010b;
  9. const int MAP_FLAG_ITEM     =   000000000100b;
  10. const int MAP_FLAG_CHEST    =   000000001000b;
  11. const int MAP_FLAG_KEY      =   000000010000b;
  12. const int MAP_FLAG_BOSSKEY  =   000000100000b;
  13. const int MAP_FLAG_BOSSCHEST    =   000001000000b;
  14. const int MAP_FLAG_SAVE     =   000010000000b;
  15. const int MAP_FLAG_BOSS     =   000100000000b;
  16. const int MAP_FLAG_MIDBOSS  =   001000000000b;
  17. const int MAP_FLAG_TRIFORCE     =   010000000000b;
  18.  
  19. void SetMapFlag(int index, int flag, bool state){
  20.     if ( state ) MapFlags[index] |= flag;
  21.     else MapFlags[index] &= ~flag;
  22. }
  23.  
  24. void GetMapFlag(int index, int flag){
  25.     return ( MapFlags[index]&flag ) != 0;
  26. }
  27.  
  28. //An arbitrary way to find the index for a specific screen and dmap.
  29. //We probably do not want to go tis route, and we'll use dmap sizing to stitch them together, then hardcode
  30. //their attributes so that we know what each index is.
  31. //
  32. //We can set constant floats for each room if desired, but this is certainly the lazy approach.
  33. int GetRoom(int dmap, int screen){
  34.     int scr; int dmp; int q; int w; int index;
  35.     for ( q = 0; q < SizeOfArray(MapDMaps); q++ ) {
  36.         if ( MapDMaps[q] == dmap && MapScreens[q] == screen ) return q;
  37.     }
  38.     return -1;
  39. }
  40.  
  41. //We draw 8x8 tiles for eacdh map space. These may be black (blank), grey (room), or blue (visited room).
  42. //We use the flags for each index to draw the rooms.
  43. const int MAP_TILE_EMPTYSPACE = 1000;
  44. const int MAP_TILE_ROOM = 1001;
  45. const int MAP_TILE_ROOMVISITED = 1002;
  46. const int MAP_ICON_ROOMITEM = 1003; //Overlay = icon
  47. const int MAP_ICON_ROOMSAVE = 1004;
  48. const int MAP_ICON_BOSS = 1005;
  49.  
  50. const int MAP_OVERALL_WIDTH_COLUMNS = 500;
  51. const int MAP_OVERALL_HEIGHT_ROWS = 100;
  52.  
  53. void DrawMapRoomsToBitmap(){
  54.     int q; int w; int x; int y;
  55.     for ( q = 0; q < SizeOfArray(MapFlags); q++ ) {
  56.         //Draw those rows
  57.         if ( q > 0 && q % MAP_OVERALL_WIDTH_COLUMNS == 0 ) { y += MAP_ROOM_Y; x = 0; } //New line
  58.         //Draw the rooms and scale them.
  59.         if ( GetMapFlag(q, MAP_FLAG_BLANK) ) DrawTile(q, MAP_TILE_EMPTYSPACE, MAP_TILE_WIDTH, MAP_TILE_HEIGHT);
  60.         if ( GetMapFlag(q, MAP_FLAG_ROOM) && !GetMapFlag(q, MAP_FLAG_VISITED) ) DrawTile(q, MAP_TILE_ROOM, MAP_TILE_WIDTH, MAP_TILE_HEIGHT);
  61.         if ( GetMapFlag(q, MAP_FLAG_ROOM) && GetMapFlag(q, MAP_FLAG_VISITED) ) DrawTile(q, MAP_TILE_VISITED, MAP_TILE_WIDTH, MAP_TILE_HEIGHT);
  62.         //Draw any room icons
  63.         if ( GetMapFlag(q, MAP_FLAG_BOSS) ) DrawTile(q, MAP_ICON_BOSS, MAP_TILE_WIDTH, MAP_TILE_HEIGHT);
  64.         if ( GetMapFlag(q, MAP_FLAG_ITEM) ) DrawTile(q, MAP_ICON_ROOMITEM, MAP_TILE_WIDTH, MAP_TILE_HEIGHT);
  65.         if ( GetMapFlag(q, MAP_FLAG_SAVE) ) DrawTile(q, MAP_ICON_ROOMSAVE, MAP_TILE_WIDTH, MAP_TILE_HEIGHT);
  66.        
  67.         //Next room
  68.         x += MAP_ROOM_X;
  69.     }
  70. }
  71.    
  72.  
  73. const int MAP_TILE_WIDTH = 8;
  74. const int MAP_ROOM_X = 10;
  75. const int MAP_ROOM_Y = 10;
  76. const int MAP_ROOM_CENTER = 2;
  77.  
  78. //We draw rooms in a pseudo-grid. Each room is a tile, drawn every ROOM_X pixels, in a row.
  79. //Each row is drawn ROOM_Y pixels below the previosu row, to the bitmap.
  80.  
  81. const int MAP_BITMAP = 4;
  82. const int MAP_SLICE_X = 200; //20 rooms.
  83. const int MAP_SLICE_Y = 120; //12 rooms.
  84.  
  85. void FindMapCentre(){} //Find the centre of the map based on the present room.
  86. const int MAP_DRAW_OFFSET_X = 100; //Half the size of the map, from the centre.
  87. const int MAP_DRAW_OFFSET_Y = 60;  //Half the size of the map, from the centre.
  88.  
  89. void MapToScreen(){
  90.     // We draw the map from the bitmap, on layer 7. To accomplish this, we find its centre, and draw the
  91.     // upper-left corner based on the true centre ( FindMapCentre() - OFFSETS), minus the offsets,
  92.     // and set the full width and height to its size (MAP_SLICE).
  93.     Screen->DrawBitmap(MAP_DRAW_LAYER, MAP_BITMAP, (FindMapCentre() - MAP_DRAW_OFFSET_X), (FindMapCentre() - MAP_DRAW_OFFSET_Y), MAP_SLICE_X, MAP_SLICE_Y, true);
  94. }
  95.    
  96. const int MAP_DRAW_LAYER = 7;
  97. const int MAP_DRAW_X = 4; //Upper-left corner of map display.
  98. const int MAP_DRAW_Y = 4;
  99.  
  100. //Dmaps
  101.  
  102. //If we predefine the exact width and height of each dmap, we can stitch them together.
  103. const int DMAP_WIDTH_1 = 16; //16 rooma
  104. const int DMAP_HEIGHT_1 = 8; //8 rooms
  105. const int DMAP_WIDTH_1 = 8; //8 rooma
  106. const int DMAP_HEIGHT_1 = 8; //8 rooms
  107. //...
  108.  
  109. ///...then we define the placement of the dmap in the overall map.
  110. const int FIRST_ROW_DMAP_1 = 0;
  111. const int FIRST_COLUMN_DMAP_1 = 0;
  112. const int LAST_COLUMN_DMAP_1 = 15;
  113. const int LAST_ROW_DMAP_1 = 7;
  114.  
  115. const int FIRST_ROW_DMAP_2 = 0;
  116. const int FIRST_COLUMN_DMAP_2 = 16; //This dmap would be stitched to the exact right of dmap 1
  117. const int LAST_COLUMN_DMAP_1 = 23; //This would be an 8x8 DMAp attached to a 16x8 DMAP.
  118. const int LAST_ROW_DMAP_1 = 7;
  119.  
  120. void DoMap(){
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement