Now have enemies chasing us around and implemented diagonal movement as a test but I kind of like it.
This commit is contained in:
parent
d5301acab5
commit
14128ab10f
5 changed files with 37 additions and 14 deletions
|
@ -67,16 +67,15 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) {
|
|||
|
||||
// sort sprites from far to close
|
||||
auto sprite_order = $level.collision->distance_sorted({(size_t)$posX, (size_t)$posY});
|
||||
|
||||
// after sorting the sprites, do the projection
|
||||
for(auto& rec : sprite_order) {
|
||||
if(!$sprites.contains(rec.second)) continue;
|
||||
// BUG: eventually this needs to go away too
|
||||
auto& sf_sprite = $sprites.at(rec.second).sprite;
|
||||
auto sprite_pos = $level.world->get<components::Position>(rec.second);
|
||||
|
||||
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) * [ ]
|
||||
|
@ -333,9 +332,10 @@ void Raycaster::set_level(GameLevel level) {
|
|||
auto& tiles = $level.map->tiles();
|
||||
$map = $textures.convert_char_to_texture(tiles.$tile_ids);
|
||||
|
||||
// this will need to go away too but for now everything is evil eye
|
||||
for(auto &thing : $level.collision->table) {
|
||||
auto sprite_txt = $textures.sprite_textures.at("evil_eye");
|
||||
$sprites.try_emplace(thing.second, sprite_txt);
|
||||
}
|
||||
$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);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue