Sprite is now a component we can place on anything to render it.
This commit is contained in:
parent
9c37960283
commit
6bca6d021e
8 changed files with 50 additions and 26 deletions
|
@ -343,19 +343,12 @@ void Raycaster::set_level(GameLevel level) {
|
|||
auto& player = world->get_the<components::Player>();
|
||||
$map = $textures.convert_char_to_texture(tiles.$tile_ids);
|
||||
|
||||
world->query<components::Position>([&](const auto ent, auto &pos) {
|
||||
world->query<components::Sprite>([&](const auto ent, auto& sprite) {
|
||||
// player doesn't need a sprite
|
||||
if(player.entity == ent) return;
|
||||
|
||||
if(world->has<components::Combat>(ent)) {
|
||||
fmt::println("enemy: {}, pos={},{}", ent, pos.location.x, pos.location.y);
|
||||
auto sprite_txt = $textures.sprite_textures.at("evil_eye");
|
||||
$sprites.try_emplace(ent, sprite_txt);
|
||||
} else {
|
||||
fmt::println("item or device: {}, pos={},{}", ent, pos.location.x, pos.location.y);
|
||||
auto sprite_txt = $textures.sprite_textures.at("barrel");
|
||||
$sprites.try_emplace(ent, sprite_txt);
|
||||
}
|
||||
fmt::println("entity {} will have sprite named {}", ent, sprite.name);
|
||||
auto sprite_txt = $textures.sprite_textures.at(sprite.name);
|
||||
$sprites.try_emplace(ent, sprite_txt);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue