// // Created by bruno on 4/24/25. // #ifndef FACTORYGAME_TILE_H #define FACTORYGAME_TILE_H #include "../util/util.h" #include "../items/item.h" //#include "../items/item.h" #define MAP_WIDTH 100 #define MAP_HEIGHT 100 #define DISPLAY_MAP_WIDTH 60 #define DISPLAY_MAP_HEIGHT 31 #define TILE_SIZE 32 #define DISPLAY_WIDTH DISPLAY_MAP_WIDTH * TILE_SIZE #define DISPLAY_HEIGHT DISPLAY_MAP_HEIGHT * TILE_SIZE extern SDL_Texture *tilesTexture; extern SDL_Texture *itemsTexture; extern SDL_Texture *backgroundTexture; extern int scrollFrame; extern unsigned long beltFrames; #define ItemSlotCount 4 typedef enum BackgroundType { BGType_WATER0, BGType_WATER1, BGType_GRASS0, BGType_GRASS1, BGType_GRASS2, BGType_GRASS3, BGType_GRASS4, BGType_GRASS5, BGType_GRASS6, BGType_GRASS7, BGType_GRASS_FLOWER0, BGType_GRASS_FLOWER1, BGType_GRASS_FLOWER2, BGType_GRASS_FLOWER3, BGType_SAND0, BGType_SAND1, BGType_SAND2, BGType_SAND3, BGType_SAND4, BGType_SAND5, BGType_SAND6, BGType_SAND7, BGType_TILES0, BGType_TILES1, BGType_TILES2, BGType_TILES3, BGType_COBBLE0, BGType_COBBLE1, BGType_COBBLE2, BGType_COBBLE3, BGType_PLATINUM_ORE, BGType_GOLD_ORE, BGType_SILVER_ORE, BGType_IRON_ORE, BGType_END } BackgroundType; typedef struct TileTypeReg { ItemType type; char name[20]; SDL_Texture *textures[ORIENT_DIRECTION_COUNT]; SDL_Rect atlasRects[ORIENT_DIRECTION_COUNT]; uint16_t breakTime; bool itemMoves; bool allowedInItems[ItemSlotCount][ITEMREGISTRY_SIZE]; bool outputLane[ItemSlotCount]; } TileTypeReg; typedef struct BackgroundTileType { ItemType type; char name[20]; SDL_Texture *texture; SDL_Rect atlasRect; } BackgroundTileType; typedef struct BackgroundTile { BackgroundType type; } BackgroundTile; #define TILEREGISTRY_SIZE 64 extern BackgroundTileType BackgroundTileRegistry[TILEREGISTRY_SIZE]; extern TileTypeReg TileRegistry[TILEREGISTRY_SIZE]; void renderAllTiles(SDL_Renderer *renderer, SDL_Rect playerRect); void updateTiles(); typedef struct Tile { OrientDirection direction; ItemType type; int miscVal; ItemOnBelt items[ItemSlotCount]; uint16_t audioCh; int x; int y; } Tile; extern Tile tileMap[MAP_HEIGHT][MAP_WIDTH]; extern BackgroundTile backgroundMap[MAP_HEIGHT][MAP_WIDTH]; void setupTiles(); void generateTestMap(); void loadTiles(SDL_Renderer *renderer); extern uint16_t tileTypeIndex; extern uint16_t backgroundTileTypeIndex; uint16_t getBreakTime(int type); void initTiles(); #endif //FACTORYGAME_TILE_H