Advertisement
Kitomas

tile.hpp as of 2024-04-26

Apr 26th, 2024
805
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.85 KB | None | 0 0
  1. #ifndef _TILE_HPP
  2. #define _TILE_HPP
  3.  
  4. #include <globals.hpp>
  5.  
  6.  
  7.  
  8.  
  9.  
  10. union Tile {
  11.   kit::u16 value;
  12.  
  13.   struct {
  14.     kit::u16        id : 7; //id of what tile to use
  15.  
  16.     kit::u16   tileset : 1; //whether to use tileset a or b
  17.  
  18.     kit::u16 collide_a : 1; //'collide with top-left 12x12 section of tile?'
  19.     kit::u16 collide_b : 1; //'collide with top-right 12x12 section of tile?'
  20.     kit::u16 collide_c : 1; //'collide with bottom-left 12x12 section of tile?'
  21.     kit::u16 collide_d : 1; //'collide with bottom-right 12x12 section of tile?'
  22.  
  23.     kit::u16      pass : 1; //allow passing through tile
  24.     kit::u16  platform : 1; //allow falling through top side of tile conditionally
  25.  
  26.     kit::u16   _unused : 2;
  27.   };
  28.  
  29.   Tile(               ) : value(             0) {}
  30.   Tile(kit::u8 _lobyte) : value(0x0f00|_lobyte) {} //assumes full collision
  31.   Tile(kit::u16 _value) : value(        _value) {}
  32.   Tile(kit::s32 _value) : value(0xffff& _value) {}
  33. };
  34.  
  35.  
  36.  
  37.  
  38.  
  39. struct Object;
  40. struct Scene;
  41.  
  42. typedef void (*Object_TickCallback)(Object* obj_a, Scene* scene);
  43.  
  44. struct Object { //32B
  45.   kit::u16                  type;
  46.   kit::u16                    _0;
  47.   kit::s16                     x;
  48.   kit::s16                     y;
  49.   Object_TickCallback funcUpdate;
  50.   kit::u64                    _1;
  51. };
  52.  
  53.  
  54.  
  55.  
  56.  
  57. //uncompressed scene data
  58. struct Scene { //64B
  59.   //pat is memory::alloc'd, bmp uses "new" instead
  60.   kit::Bitmap* bmp_bg = nullptr; //bitmap for background layer
  61.   Tile*        pat_mg = nullptr; //pattern for midground (collision) layer
  62.   Tile*        pat_fg = nullptr; //pattern for foreground layer (skipped if nullptr)
  63.   //(length of pat_<mg/fg> is [TILESIZ_X*TILESIZ_Y])
  64.  
  65.   //these two are memory::alloc'd too
  66.   Object*  objs          = nullptr; //pointer to associated object array,
  67.   Object*  objs_original = nullptr;  //and whatever its original state was
  68.   kit::u16 objs_len      = 0;
  69.  
  70.   //associated edges can be manipulated by game states
  71.   kit::u16   edge_n; //scene id for north edge
  72.   kit::u16   edge_s; //scene id for south edge
  73.   kit::u16   edge_w; //scene id for west edge
  74.   kit::u16   edge_e; //scene id for east edge
  75.   kit::u16 scene_id; //scene id for scene itself
  76.  
  77.   kit::u16     music = 0; //music id;  0 for no change, -1 (65535) to stop
  78.   kit::u16 ambient_a = 0; //ambient track id a;  0 for no change, -1 to stop
  79.   kit::u16 ambient_b = 0; //ambient track id b;  0 for no change, -1 to stop
  80.  
  81.   kit::u16     tileset_a = 0; //1st associated tileset
  82.   kit::u16     tileset_b = 0; //2nd associated tileset
  83.   kit::u8 visited_before = 0; //used to reset object (including npc) properties between deaths
  84.   bool        stretch_bg = true; //'stretch the bg over the entire screen?' (repeats otherwise)
  85.  
  86.  
  87.   void drawBg();
  88.  
  89.   void drawTiles(bool drawForeground = false); //draws midground if false
  90. };
  91.  
  92.  
  93.  
  94.  
  95.  
  96. #endif /* _TILE_HPP */
  97.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement