// // Created by bruno on 4/24/25. // #include "belt.h" #include "../util/util.h" #include "tile.h" #include "../player/player.h" #include "../items/item.h" void renderBelt(int x, int y, int w, int h, OrientDirection dir, SDL_Rect playerRect, SDL_Renderer *renderer) { int px = x * TILE_SIZE; int py = y * TILE_SIZE; Tile *t = &tileMap[y][x]; ItemType tileType = t->type; SDL_Rect src1, src2, dst1, dst2; if (dir == ORIENT_LEFT || dir == ORIENT_RIGHT) { int offset = scrollFrame % TILE_SIZE; if (dir == ORIENT_RIGHT) { offset = TILE_SIZE - offset; // reverse scroll } src1 = (SDL_Rect) {offset, 0, TILE_SIZE - offset, TILE_SIZE}; dst1 = (SDL_Rect) {px, py, (w - offset), h}; src2 = (SDL_Rect) {0, 0, offset, TILE_SIZE}; dst2 = (SDL_Rect) {px + (w - offset), py, offset, h}; adjustRect(&dst1, playerRect); adjustRect(&dst2, playerRect); SDL_RenderCopy(renderer, TileRegistry[tileType].textures[dir], &src1, &dst1); SDL_RenderCopy(renderer, TileRegistry[tileType].textures[dir], &src2, &dst2); } else { int offset = scrollFrame % TILE_SIZE; if (dir == ORIENT_DOWN) { offset = TILE_SIZE - offset; // reverse scroll } src1 = (SDL_Rect) {0, offset, TILE_SIZE, TILE_SIZE - offset}; dst1 = (SDL_Rect) {px, py, w, h - offset}; src2 = (SDL_Rect) {0, 0, TILE_SIZE, offset}; dst2 = (SDL_Rect) {px, py + (h - offset), w, offset}; adjustRect(&dst1, playerRect); adjustRect(&dst2, playerRect); // Rotate to make the belt vertical SDL_RenderCopy(renderer, TileRegistry[tileType].textures[dir], &src1, &dst1); SDL_RenderCopy(renderer, TileRegistry[tileType].textures[dir], &src2, &dst2); } } void updateBelt(Tile * tile) { }