Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef _TILE_HPP
- #define _TILE_HPP
- #include <globals.hpp>
- union Tile {
- kit::u16 value;
- struct {
- kit::u16 id : 7; //id of what tile to use
- kit::u16 tileset : 1; //whether to use tileset a or b
- kit::u16 collide_a : 1; //'collide with top-left 12x12 section of tile?'
- kit::u16 collide_b : 1; //'collide with top-right 12x12 section of tile?'
- kit::u16 collide_c : 1; //'collide with bottom-left 12x12 section of tile?'
- kit::u16 collide_d : 1; //'collide with bottom-right 12x12 section of tile?'
- kit::u16 pass : 1; //allow passing through tile
- kit::u16 platform : 1; //allow falling through top side of tile conditionally
- kit::u16 _unused : 2;
- };
- Tile( ) : value( 0) {}
- Tile(kit::u8 _lobyte) : value(0x0f00|_lobyte) {} //assumes full collision
- Tile(kit::u16 _value) : value( _value) {}
- Tile(kit::s32 _value) : value(0xffff& _value) {}
- };
- struct Object;
- struct Scene;
- typedef void (*Object_TickCallback)(Object* obj_a, Scene* scene);
- struct Object { //32B
- kit::u16 type;
- kit::u16 _0;
- kit::s16 x;
- kit::s16 y;
- Object_TickCallback funcUpdate;
- kit::u64 _1;
- };
- //uncompressed scene data
- struct Scene { //64B
- //pat is memory::alloc'd, bmp uses "new" instead
- kit::Bitmap* bmp_bg = nullptr; //bitmap for background layer
- Tile* pat_mg = nullptr; //pattern for midground (collision) layer
- Tile* pat_fg = nullptr; //pattern for foreground layer (skipped if nullptr)
- //(length of pat_<mg/fg> is [TILESIZ_X*TILESIZ_Y])
- //these two are memory::alloc'd too
- Object* objs = nullptr; //pointer to associated object array,
- Object* objs_original = nullptr; //and whatever its original state was
- kit::u16 objs_len = 0;
- //associated edges can be manipulated by game states
- kit::u16 edge_n; //scene id for north edge
- kit::u16 edge_s; //scene id for south edge
- kit::u16 edge_w; //scene id for west edge
- kit::u16 edge_e; //scene id for east edge
- kit::u16 scene_id; //scene id for scene itself
- kit::u16 music = 0; //music id; 0 for no change, -1 (65535) to stop
- kit::u16 ambient_a = 0; //ambient track id a; 0 for no change, -1 to stop
- kit::u16 ambient_b = 0; //ambient track id b; 0 for no change, -1 to stop
- kit::u16 tileset_a = 0; //1st associated tileset
- kit::u16 tileset_b = 0; //2nd associated tileset
- kit::u8 visited_before = 0; //used to reset object (including npc) properties between deaths
- bool stretch_bg = true; //'stretch the bg over the entire screen?' (repeats otherwise)
- void drawBg();
- void drawTiles(bool drawForeground = false); //draws midground if false
- };
- #endif /* _TILE_HPP */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement