Trabajando en el marcador

This commit is contained in:
2022-09-21 22:41:08 +02:00
parent 488e603ca5
commit bc0bd2a4e2
6 changed files with 124 additions and 19 deletions

View File

@@ -407,11 +407,11 @@ void Map::fillMapTexture()
SDL_RenderClear(renderer);
// Dibuja el degradado de fondo
const int num_lines = 208;
const float num_lines = PLAY_AREA_BOTTOM - PLAY_AREA_TOP;
for (int i = 0; i < num_lines; i++)
for (int i = PLAY_AREA_TOP; i < PLAY_AREA_BOTTOM; i++)
{
float step = ((float)i / (float)num_lines);
float step = ((float)i / num_lines);
int r = bgColor1.r + ((bgColor2.r - bgColor1.r) * step);
int g = bgColor1.g + ((bgColor2.g - bgColor1.g) * step);
int b = bgColor1.b + ((bgColor2.b - bgColor1.b) * step);
@@ -428,17 +428,8 @@ void Map::fillMapTexture()
// con lo que esta pintando desde fuera de la textura
clip.x = ((tilemap_l0[(y * map_width) + x] - 1) % tileset_width) * tile_size;
clip.y = ((tilemap_l0[(y * map_width) + x] - 1) / tileset_width) * tile_size;
texture_tile->render(renderer, x * tile_size, y * tile_size, &clip);
texture_tile->render(renderer, x * tile_size, (y * tile_size) + PLAY_AREA_TOP, &clip);
}
// Dibuja el degradado del marcador
int color = 105;
for (int i = 208; i < 240; i++)
{
SDL_SetRenderDrawColor(renderer, 0x69, color, 0x69, 0xFF);
SDL_RenderDrawLine(renderer, 0, i, 320, i);
color--;
}
}
// Rellena la capa 1
@@ -457,7 +448,7 @@ void Map::fillMapTexture()
// con lo que esta pintando desde fuera de la textura
clip.x = ((tilemap_l1[(y * map_width) + x] - 1) % tileset_width) * tile_size;
clip.y = ((tilemap_l1[(y * map_width) + x] - 1) / tileset_width) * tile_size;
texture_tile->render(renderer, x * tile_size, y * tile_size, &clip);
texture_tile->render(renderer, x * tile_size, (y * tile_size) + PLAY_AREA_TOP, &clip);
}
}
@@ -496,7 +487,7 @@ e_tile_map Map::getTile(SDL_Point p)
const int y = std::max(getPlayArea(b_top), (std::min(p.y, getPlayArea(b_bottom) - 1)));
// Calcula el tile
const int tile = collisionmap[((y / tile_size) * map_width) + (x / tile_size)];
const int tile = collisionmap[(((y + PLAY_AREA_TOP) / tile_size) * map_width) + (x / tile_size)];
// Las 8 primeras filas son tiles de fondo
if (tile == 0)