Some progress

This commit is contained in:
2025-05-29 22:37:44 +02:00
parent f6e59e74c7
commit d01bdbe819
11 changed files with 331 additions and 65 deletions

View File

@@ -17,7 +17,7 @@ void renderBelt(int x, int y, int w, int h, OrientDirection dir, SDL_Renderer *r
int px = x * TILE_SIZE;
int py = y * TILE_SIZE;
uint16_t tileType = tileMap[y][x].type;
uint16_t tileType = tileMap[y][x].type - 1;
SDL_Rect src1, src2, dst1, dst2;
@@ -64,7 +64,7 @@ void renderBelt(int x, int y, int w, int h, OrientDirection dir, SDL_Renderer *r
void renderAllBelts(SDL_Renderer *renderer) {
int scrollSpeed = 0; // pixels per step
int scrollSpeed = 1; // pixels per step
int scrollDelay = 1; // frames between steps
if (beltFrames++ % scrollDelay == 0) {
@@ -72,19 +72,31 @@ void renderAllBelts(SDL_Renderer *renderer) {
}
int tileSize = TILE_SIZE;
for (int y = (playerY / TILE_SIZE) - (DISPLAY_MAP_HEIGHT / 2);
y < (playerY / TILE_SIZE) + (DISPLAY_MAP_HEIGHT / 2); y++) {
for (int x = (playerX / TILE_SIZE) - (DISPLAY_MAP_WIDTH / 2);
x < (playerX / TILE_SIZE) + (DISPLAY_MAP_WIDTH / 2); x++) {
for (int y = (playerY / TILE_SIZE) - (DISPLAY_MAP_HEIGHT / 2) - 1;
y < (playerY / TILE_SIZE) + (DISPLAY_MAP_HEIGHT / 2) + 1; y++) {
if (y < 0 || y >= MAP_HEIGHT) {
continue;
}
for (int x = (playerX / TILE_SIZE) - (DISPLAY_MAP_WIDTH / 2) - 1;
x < (playerX / TILE_SIZE) + (DISPLAY_MAP_WIDTH / 2) + 1; x++) {
if (x < 0 || x >= MAP_WIDTH) {
continue;
}
Tile t = tileMap[y][x];
if (t.type != TYPE_BELT) continue;
renderBelt(x, y, tileSize, tileSize, t.direction, renderer);
}
}
for (int y = (playerY / TILE_SIZE) - (DISPLAY_MAP_HEIGHT / 2);
y < (playerY / TILE_SIZE) + (DISPLAY_MAP_HEIGHT / 2); y++) {
for (int x = (playerX / TILE_SIZE) - (DISPLAY_MAP_WIDTH / 2);
x < (playerX / TILE_SIZE) + (DISPLAY_MAP_WIDTH / 2); x++) {
for (int y = (playerY / TILE_SIZE) - (DISPLAY_MAP_HEIGHT / 2) - 1;
y < (playerY / TILE_SIZE) + (DISPLAY_MAP_HEIGHT / 2) + 1; y++) {
if (y < 0 || y >= MAP_HEIGHT) {
continue;
}
for (int x = (playerX / TILE_SIZE) - (DISPLAY_MAP_WIDTH / 2) - 1;
x < (playerX / TILE_SIZE) + (DISPLAY_MAP_WIDTH / 2) + 1; x++) {
if (x < 0 || x >= MAP_WIDTH) {
continue;
}
Tile t = tileMap[y][x];
if (t.type != TYPE_BELT) continue;
for (uint8_t lane = 0; lane < 2; lane++) {