Trying a new 'glowing moss' texture to sort out how to make the raycaster alter the light of a surface that has its own light.

This commit is contained in:
Zed A. Shaw 2025-05-24 00:47:44 -04:00
parent e361984c40
commit 9dcc2036aa
12 changed files with 109 additions and 51 deletions

40
map.cpp
View file

@ -46,12 +46,8 @@ void Map::clear_target(const Point &at) {
bool Map::place_entity(size_t room_index, Point &out) {
dbc::check($dead_ends.size() != 0, "no dead ends?!");
if($rooms.size() == 0) {
out = $dead_ends.at(room_index % $dead_ends.size());
return true;
} else {
dbc::check(room_index < $rooms.size(), "room_index is out of bounds, not enough rooms");
if(room_index < $rooms.size()) {
Room &start = $rooms.at(room_index);
for(matrix::rando_rect it{$walls, start.x, start.y, start.width, start.height}; it.next();) {
@ -61,9 +57,10 @@ bool Map::place_entity(size_t room_index, Point &out) {
return true;
}
}
return false;
}
out = $dead_ends.at(room_index % $dead_ends.size());
return true;
}
bool Map::iswall(size_t x, size_t y) {
@ -151,23 +148,20 @@ void Map::load_tiles() {
$tiles.load($walls);
}
void Map::expand() {
// adjust width first
for(auto &row : $walls) {
row.insert(row.begin(), WALL_VALUE);
row.push_back(WALL_VALUE);
void Map::enclose() {
std::array<Point, 4> starts{{
{0,0}, {$width-1, 0}, {$width-1, $height-1}, {0, $height-1}
}};
std::array<Point, 4> ends{{
{$width-1, 0}, {$width-1, $height-1}, {0, $height-1}, {0,0},
}};
for(size_t i = 0; i < starts.size(); i++) {
for(matrix::line it{starts[i], ends[i]}; it.next();) {
$walls[it.y][it.x] = 1;
}
}
$width = matrix::width($walls);
// then add two new rows top/bottom of that new width
$walls.insert($walls.begin(), matrix::Row($width, WALL_VALUE));
$walls.push_back(matrix::Row($width, WALL_VALUE));
// now we have the new height
$height = matrix::height($walls);
// reset the pathing and tiles and done
$paths = Pathing($width, $height);
$tiles = TileMap($width, $height);
}
void Map::add_room(Room &room) {