DungeonCrawl
|
Implements functionality fro drawing light on player. More...
Go to the source code of this file.
Functions | |
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. | |
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 | 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. | |
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. |
Variables | |
map_tile_t * | map_arr |
map_tile_t * | revealed_map_arr |
int | map_height |
int | map_width |
vector2d_t | player_position |
int | radius |
const vector2d_t | checks_vector [4][2] |
Each array row corresponds to the vector in the directions array. |
Implements functionality fro drawing light on player.
Definition in file draw_light.c.
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.
x | current tile x-coordinates |
y | current tile y-coordinates |
prev_wall_at | index of the previous wall tile |
dir | the direction to check |
j | loop counter |
diagonal_check | the diagonal check vector |
reverse_check | the reverse check vector |
Definition at line 88 of file draw_light.c.
void draw_light_on_player | ( | map_tile_t * | arr1, |
map_tile_t * | arr2, | ||
int | height, | ||
int | width, | ||
vector2d_t | player, | ||
int | light_radius ) |
Draws light around the player.
arr1 | The pointer to the 2D array containing all the map tiles (no Hidden tiles) |
arr2 | The pointer to the 2D array to reveal the arr1, based on the player's position and light radius |
height | The height of the map |
width | The width of the map |
player | The player's position on the map |
light_radius | The radius of the light around the player |
Definition at line 156 of file draw_light.c.
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.
x | current tile x-coordinates |
y | current tile y-coordinates |
dir | the direction to check |
j | loop counter |
prev_wall_at | pointer to variable, which should be written |
Definition at line 39 of file draw_light.c.
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.
player | the player's position on the map_arr |
dir | the direction vector |
diagonal_check | the diagonal check vector |
reverse_check | the reverse check vector |
light_radius | the radius of the light around the player |
Definition at line 126 of file draw_light.c.
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.
x | current tile x-coordinates |
y | current tile y-coordinates |
prev_wall_at | index of the previous wall tile |
dir | the direction to check |
j | loop counter |
Definition at line 63 of file draw_light.c.
const vector2d_t checks_vector[4][2] |
Each array row corresponds to the vector in the directions array.
A row contains:
Definition at line 22 of file draw_light.c.
map_tile_t* map_arr |
Definition at line 9 of file draw_light.c.
int map_height |
Definition at line 11 of file draw_light.c.
int map_width |
Definition at line 12 of file draw_light.c.
vector2d_t player_position |
Definition at line 13 of file draw_light.c.
int radius |
Definition at line 14 of file draw_light.c.
map_tile_t* revealed_map_arr |
Definition at line 10 of file draw_light.c.