upd
This commit is contained in:
28
tiles/belt.c
28
tiles/belt.c
@@ -12,7 +12,7 @@ static int scrollFrame = 0;
|
||||
unsigned long beltFrames = 0;
|
||||
|
||||
|
||||
void renderBelt(int x, int y, int w, int h, OrientDirection dir, SDL_Renderer * renderer) {
|
||||
void renderBelt(int x, int y, int w, int h, OrientDirection dir, SDL_Renderer *renderer) {
|
||||
|
||||
int px = x * TILE_SIZE;
|
||||
int py = y * TILE_SIZE;
|
||||
@@ -63,8 +63,8 @@ void renderBelt(int x, int y, int w, int h, OrientDirection dir, SDL_Renderer *
|
||||
}
|
||||
|
||||
|
||||
void renderAllBelts(SDL_Renderer * renderer) {
|
||||
int scrollSpeed = 1; // pixels per step
|
||||
void renderAllBelts(SDL_Renderer *renderer) {
|
||||
int scrollSpeed = 0; // pixels per step
|
||||
int scrollDelay = 1; // frames between steps
|
||||
|
||||
if (beltFrames++ % scrollDelay == 0) {
|
||||
@@ -72,13 +72,27 @@ 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);
|
||||
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++) {
|
||||
Tile t = tileMap[y][x];
|
||||
if (t.type != TYPE_BELT) continue;
|
||||
renderBelt(x, y, tileSize, tileSize, t.direction, renderer);
|
||||
if (t.item.active) {
|
||||
renderItem(t.item, 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++) {
|
||||
Tile t = tileMap[y][x];
|
||||
if (t.type != TYPE_BELT) continue;
|
||||
for (uint8_t lane = 0; lane < 2; lane++) {
|
||||
for (uint8_t itemIndex = 0; itemIndex < 2; itemIndex++) {
|
||||
if (t.items[lane][itemIndex].active) {
|
||||
renderItem(t.items[lane][itemIndex], renderer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -31,7 +31,8 @@ void generateTestMap() {
|
||||
tileMap[y][x].type = TYPE_BELT;
|
||||
tileMap[y][x].frameOffset = 0;
|
||||
//tileMap[y][x].direction = ((x + y) % 4 * 2) + 1;
|
||||
tileMap[y][x].direction = 5;
|
||||
//tileMap[y][x].direction = 5;
|
||||
tileMap[y][x].direction = (rand() % 4 * 2) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ typedef struct {
|
||||
OrientDirection direction;
|
||||
uint16_t type;
|
||||
int frameOffset;
|
||||
ItemOnBelt item;
|
||||
ItemOnBelt items[2][2];
|
||||
int x;
|
||||
int y;
|
||||
} Tile;
|
||||
|
Reference in New Issue
Block a user