Removing natural lighting debug.

After implementing line of sight light it did not look good at all with
this size of tiles. Keeping as is for now.
This commit is contained in:
Linus Probert 2018-08-04 14:07:17 +02:00
parent c16caf30b5
commit 56af37edb0
3 changed files with 9 additions and 60 deletions

View File

@ -185,7 +185,6 @@ target_link_libraries(breakhack
${SDL2_IMAGE_LIBRARY}
${SDL2_TTF_LIBRARY}
${SDL2_MIXER_LIBRARY}
m # We need the math library
)
if (NOT PHYSFS_FOUND)

View File

@ -573,10 +573,6 @@ run_game_render(void)
}
pointer_render(gPointer, gCamera);
#ifdef DEBUG
roommatrix_render_debug(gRoomMatrix, gCamera);
#endif
SDL_RenderPresent(gRenderer);
}

View File

@ -181,8 +181,6 @@ roommatrix_add_lightsource(RoomMatrix *matrix, Position *pos)
static void
set_light_for_tile(RoomMatrix *matrix, int x, int y)
{
int x_max, x_min, y_max, y_min, i, j;
int lightval, distance_modifier;
RoomSpace *space;
space = &matrix->spaces[x][y];
@ -191,15 +189,16 @@ set_light_for_tile(RoomMatrix *matrix, int x, int y)
space->light = 255;
x_max = min(x + 5, MAP_ROOM_WIDTH - 1);
x_min = max(x - 5, 0);
y_max = min(y + 5, MAP_ROOM_HEIGHT - 1);
y_min = max(y - 5, 0);
Uint8 radius = 4;
int x_max = min(x + radius, MAP_ROOM_WIDTH - 1);
int x_min = max(x - radius, 0);
int y_max = min(y + radius, MAP_ROOM_HEIGHT - 1);
int y_min = max(y - radius, 0);
for (i = x_min; i <= x_max; ++i) {
for (j = y_min; j <= y_max; ++j) {
lightval = matrix->spaces[i][j].light;
distance_modifier = abs(x-i) == abs(y-j) ?
for (int i = x_min; i <= x_max; ++i) {
for (int j = y_min; j <= y_max; ++j) {
int lightval = matrix->spaces[i][j].light;
int distance_modifier = abs(x-i) == abs(y-j) ?
min(abs(x-i) + 1, 5) : max(abs(x-i), abs(y-j));
lightval += (255 - (distance_modifier * 50));
lightval = min(255, lightval);
@ -266,51 +265,6 @@ roommatrix_render_lightmap(RoomMatrix *matrix, Camera *cam)
}
}
#ifdef DEBUG
static void
draw_raycasts_from(int x, int y, Camera *cam)
{
double length = 4*32;
double x1 = x * 32 + 16;
double y1 = y * 32 + 16;
double angle = 0;
while (angle < 360) {
double x2 = x1 + length * cos(angle);
double y2 = y1 + length * sin(angle);
//printf("Drawing line: %fx%f -> %fx%f\n", x1, y1, x2, y2);
SDL_RenderDrawLine(cam->renderer,
(int) x1,
(int) y1,
(int) x2,
(int) y2);
angle += 7.5;
}
}
void
roommatrix_render_debug(RoomMatrix *rm, Camera *cam)
{
SDL_SetRenderDrawColor(cam->renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
for (int i = 0; i < MAP_ROOM_HEIGHT; ++i) {
SDL_RenderDrawLine(cam->renderer, 0, i*32, MAP_ROOM_WIDTH*32, i*32);
}
for (int i = 0; i < MAP_ROOM_WIDTH; ++i) {
SDL_RenderDrawLine(cam->renderer, i*32, 0, i*32, MAP_ROOM_HEIGHT*32);
}
// Draw raycasts
SDL_SetRenderDrawColor(cam->renderer, 255, 255, 255, 100);
for (int i = 0; i < MAP_ROOM_WIDTH; ++i) {
for (int j = 0; j < MAP_ROOM_HEIGHT; ++j) {
if (rm->spaces[i][j].lightsource) {
draw_raycasts_from(i, j, cam);
}
}
}
}
#endif
void roommatrix_destroy(RoomMatrix *m)
{
// Clear the list but don't destroy the items