DungeonCrawl
Loading...
Searching...
No Matches
draw_light.h File Reference

Exposes functions for drawing light on player. More...

#include "../map.h"

Go to the source code of this file.

Functions

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.

Detailed Description

Exposes functions for drawing light on player.

Definition in file draw_light.h.

Function Documentation

◆ draw_light_on_player()

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.

Parameters
arr1The pointer to the 2D array containing all the map tiles (no Hidden tiles)
arr2The pointer to the 2D array to reveal the arr1, based on the player's position and light radius
heightThe height of the map
widthThe width of the map
playerThe player's position on the map
light_radiusThe radius of the light around the player

Definition at line 156 of file draw_light.c.

157 {
158 map_arr = arr1;
159 revealed_map_arr = arr2;
160 map_height = height;
161 map_width = width;
162 player_position = player;
163 radius = light_radius;
164
165 if (light_radius <= 0) {
166 //light radius is negative or 0, do nothing
167 return;
168 }
169
170 for (int i = 0; i < 4; i++) {
171 const vector2d_t dir = directions[i];
172 const vector2d_t diagonal_check = checks_vector[i][0];
173 const vector2d_t reverse_check = checks_vector[i][1];
174
175 process_light_in_direction(player, dir, diagonal_check, reverse_check, light_radius);
176 }
177}
const vector2d_t checks_vector[4][2]
Each array row corresponds to the vector in the directions array.
Definition draw_light.c:22
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.
Definition draw_light.c:126
2-dimensional vector struct
Definition common.h:164