Movement is more correct now since it uses the System::motion to do it for the player, which will always keep all the things updated. I also put placeholder barrels for all the non-combatant entities in the map. Finally, it still has the backup bug and now won't close when you close the window.
This commit is contained in:
parent
14128ab10f
commit
4b18b21861
3 changed files with 24 additions and 13 deletions
|
@ -76,6 +76,7 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) {
|
|||
|
||||
double spriteX = double(sprite_pos.location.x) - $posX + 0.5;
|
||||
double spriteY = double(sprite_pos.location.y) - $posY + 0.5;
|
||||
|
||||
//transform sprite with the inverse camera matrix
|
||||
// [ $planeX $dirX ] -1 [ $dirY -$dirX ]
|
||||
// [ ] = 1/($planeX*$dirY-$dirX*$planeY) * [ ]
|
||||
|
@ -330,12 +331,18 @@ void Raycaster::draw(sf::RenderTarget& target) {
|
|||
void Raycaster::set_level(GameLevel level) {
|
||||
$level = level;
|
||||
auto& tiles = $level.map->tiles();
|
||||
auto world = $level.world;
|
||||
$map = $textures.convert_char_to_texture(tiles.$tile_ids);
|
||||
|
||||
$level.world->query<components::Combat, components::Position>([&](const auto ent, auto& combat, auto &pos) {
|
||||
fmt::println("entity: {}, hp: {}, pos={},{}", ent, combat.hp, pos.location.x, pos.location.y);
|
||||
|
||||
auto sprite_txt = $textures.sprite_textures.at("evil_eye");
|
||||
$sprites.try_emplace(ent, sprite_txt);
|
||||
world->query<components::Position>([&](const auto ent, auto &pos) {
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue