10map_tile_t* revealed_map_arr;
42 *prev_wall_at = abs(y * dir.dy + x * dir.dx);
45 if (*prev_wall_at == abs(y * dir.dy + x * dir.dx)) {
66 const int access_idx = x * map_height + y;
68 revealed_map_arr[access_idx] = map_arr[access_idx];
70 if (map_arr[access_idx] == WALL) {
92 const int access_idx = x * map_height + y;
94 if (x < 0 || x >= map_width || y < 0 || y >= map_height) {
98 if (revealed_map_arr[access_idx] == HIDDEN) {
100 const int rel_diagonal = map_arr[(x + diagonal_check.dx) * map_height + y + diagonal_check.dy];
101 const int rel_reverse = map_arr[(x + reverse_check.dx) * map_height + y + reverse_check.dy];
103 if (rel_diagonal == WALL && rel_reverse == WALL && j > 1) {
110 }
else if (revealed_map_arr[access_idx] == WALL &&
need_loop_break(x, y, dir, j, prev_wall_at)) {
127 const vector2d_t reverse_check,
const int light_radius) {
129 int prev_wall_at = -1;
131 for (
int j = 0; j <= light_radius; j++) {
132 const int start_x = player.dx + j * dir.dy;
133 int start_y = player.dy + j * dir.dx;
137 start_y = player.dy - j * dir.dx;
140 if (start_x < 0 || start_x >= map_width || start_y < 0 || start_y >= map_height) {
144 for (
int k = 1; k <= light_radius - correction; k++) {
145 const int x = start_x + k * dir.dx;
146 const int y = start_y + k * dir.dy;
157 const int light_radius) {
159 revealed_map_arr = arr2;
162 player_position = player;
163 radius = light_radius;
165 if (light_radius <= 0) {
170 for (
int i = 0; i < 4; i++) {
int need_loop_break(const int x, const int y, const vector2d_t dir, int j, int *prev_wall_at)
This is a helper function to check if the loop needs to break with this specific edge case.
int process_tile(int x, int y, int *prev_wall_at, const vector2d_t dir, int j)
This function processes the tile at the given coordinates and updates the revealed_map_arr array.
const vector2d_t checks_vector[4][2]
Each array row corresponds to the vector in the directions array.
void process_light_in_direction(const vector2d_t player, const vector2d_t dir, const vector2d_t diagonal_check, const vector2d_t reverse_check, const int light_radius)
Processes light in a specific direction and updates the revealed map_arr.
int check_and_process_tile(int x, int y, int *prev_wall_at, const vector2d_t dir, int j, const vector2d_t diagonal_check, const vector2d_t reverse_check)
This function checks if the tile at the given coordinates is valid and processes it.
void draw_light_on_player(map_tile_t *arr1, map_tile_t *arr2, int height, int width, vector2d_t player, const int light_radius)
Draws light around the player.
Exposes functions for drawing light on player.
2-dimensional vector struct