Maps are back and have color now. TileCell needs a rework.

master
Zed A. Shaw 4 weeks ago
parent 27bb08d62c
commit a4c13f7fc9
  1. 4
      assets/config.json
  2. 6
      components.hpp
  3. 4
      raycaster.cpp
  4. 2
      systems.cpp

@ -14,8 +14,8 @@
"player": {
},
"worldgen": {
"enemy_probability": 50,
"enemy_probability": 20,
"empty_room_probability": 10,
"device_probability": 10
"device_probability": 20
}
}

@ -28,12 +28,6 @@ namespace components {
std::string chr;
std::array<uint8_t, 3> foreground;
std::array<uint8_t, 3> background;
uint8_t fg_h = 200;
uint8_t fg_s = 20;
uint8_t fg_v = 200;
uint8_t bg_h = 100;
uint8_t bg_s = 20;
uint8_t bg_v = 0;
};
struct GameConfig {

@ -123,6 +123,8 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) {
if(drawEndY >= $height) drawEndY = $height - 1;
int texX = int(textureWidth * (drawStartX - (-spriteWidth / 2 + spriteScreenX)) * textureWidth / spriteWidth) / textureWidth;
int texRenderWidth = texX_end - texX;
if(texRenderWidth <= 0) continue;
float x = float(drawStartX + RAY_VIEW_X);
float y = float(drawStartY + RAY_VIEW_Y);
@ -133,7 +135,7 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) {
int texY = ((d * textureHeight) / spriteHeight) / textureHeight;
sf_sprite->setScale({sprite_w, sprite_h});
$anim.step(*sf_sprite, texX, texY, texX_end - texX, textureHeight);
$anim.step(*sf_sprite, texX, texY, texRenderWidth, textureHeight);
sf_sprite->setPosition({x, y});
$brightness.setUniform("offsetFactor", sf::Glsl::Vec2{0.0f, 0.0f});

@ -242,7 +242,7 @@ void System::draw_entities(DinkyECS::World &world, Map &map, const Matrix &light
// 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, [tile, light_value, cell](auto &pixel) {
pixel.foreground_color = Color::HSV(tile.fg_h, tile.fg_s, tile.fg_v * light_value);
pixel.foreground_color = Color::HSV(tile.foreground[0], tile.foreground[1], tile.foreground[2] * light_value);
pixel.background_color = Color::HSV(cell.bg_h, cell.bg_s, cell.bg_v * light_value);
});
}

Loading…
Cancel
Save