The next little game in the series where I make a fancy rogue game.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
roguish/lights.hpp

56 lines
1.2 KiB

#pragma once
#include <array>
#include "dbc.hpp"
#include "point.hpp"
#include <algorithm>
#include "matrix.hpp"
#include "pathing.hpp"
namespace lighting {
struct LightSource {
int strength = 0; // lower is better
int distance = 1; // higher is farther, in squares
};
const int MIN = 40;
const int MAX = 220;
const int MID = 140;
const std::array<int, 10> LEVELS{
MAX,
200,
180,
160,
MID,
120,
100,
80,
60,
MIN,
};
class LightRender {
public:
size_t $width;
size_t $height;
Matrix $lightmap;
Pathing $paths;
LightRender(size_t width, size_t height) :
$width(width),
$height(height),
$lightmap(height, matrix::Row(width, 0)),
$paths(width, height)
{}
void reset_light();
void set_light_target(const Point &at, int value=0);
void clear_light_target(const Point &at);
void path_light(Matrix &walls);
void light_box(LightSource source, Point from, Point &min_out, Point &max_out);
int light_level(int level, size_t x, size_t y);
void render_light(LightSource source, Point at);
Matrix &lighting() { return $lightmap; }
};
}