Entities now look like they stand on the tiles.

main
Zed A. Shaw 4 days ago
parent 857cd2f910
commit 8a94108874
  1. 2
      assets/tiles.json
  2. 1
      status.txt
  3. 8
      systems.cpp
  4. 4
      worldbuilder.cpp

@ -27,6 +27,6 @@
"WATER_TILE": {
"foreground": [132, 200, 0],
"background": [147, 220, 2],
"display":"\u224b"
"display":"\u098c"
}
}

@ -1,5 +1,6 @@
TODAY'S GOAL:
* Tile component needs to go, use the Tiles from the json.
* Fire icon \u2034
* Water icon \u224b
* Flame pillars icon \u2e3e

@ -155,6 +155,7 @@ void System::collision(DinkyECS::World &world, Player &player) {
// BUG: this is kind of massive, need to maybe rethink how systems are designed. I mean...can each system be a callable class instead?
void System::draw_entities(DinkyECS::World &world, Map &game_map, const Matrix &lighting, ftxui::Canvas &canvas, const Point &cam_orig, size_t view_x, size_t view_y) {
auto &tiles = game_map.tiles();
world.query<Position, Tile>([&](const auto &ent, auto &pos, auto &tile) {
if(pos.location.x >= cam_orig.x && pos.location.x <= cam_orig.x + view_x
@ -162,13 +163,12 @@ void System::draw_entities(DinkyECS::World &world, Map &game_map, const Matrix &
Point loc = game_map.map_to_camera(pos.location, cam_orig);
int light_value = lighting[pos.location.y][pos.location.x];
// BUG: foreground color needs to come from entity and background color from the surface they're on
const TileCell& cell = tiles.at(pos.location.x, pos.location.y);
// the 2 and 4 are from ftxui::Canvas since it does a kind of "subpixel" drawing
canvas.DrawText(loc.x*2, loc.y*4, tile.chr, [light_value](auto &pixel) {
canvas.DrawText(loc.x*2, loc.y*4, tile.chr, [light_value, cell](auto &pixel) {
pixel.foreground_color = Color::HSV(255, 200, light_value + 20);
pixel.background_color = Color::HSV(30, 20, light_value / 3);
pixel.background_color = Color::HSV(cell.bg_h, cell.bg_s, light_value / cell.bg_v);
});
}
});

@ -144,7 +144,9 @@ void WorldBuilder::generate() {
Point center = $map.place_entity(1);
for(matrix::circle it{$map.$walls, center, 3}; it.next();) {
for(int x = it.left; x < it.right; x++) {
$map.$tiles.set_tile(x, it.y, "WATER_TILE");
if(!$map.iswall(x, it.y)) {
$map.$tiles.set_tile(x, it.y, "WATER_TILE");
}
}
}
}

Loading…
Cancel
Save