feat(entities): light_radius + getLightCenter a Entity i Player
This commit is contained in:
1 parent
68be8e55ec
commit
ebb161f1f5
5 files changed
+67
No files matched your search
@@ -141,6 +141,14 @@ void Player::loadFrom(const std::string& yaml_path) {
|
||||
// `duration_ms` és 0 (o el bloc manca) la mecànica queda
|
||||
// desactivada i els hazards toquen al primer frame, com abans.
|
||||
readImmunityBlock(yaml);
|
||||
|
||||
// Bloc opcional `light: { radius: N }` — radi en píxels del cercle
|
||||
// de llum emès pel jugador. 0 = no emet. La forma del gradient és
|
||||
// global (data/config/lighting.yaml), no per jugador.
|
||||
light_radius = 0;
|
||||
if (yaml.contains("light") && yaml["light"].contains("radius")) {
|
||||
light_radius = yaml["light"]["radius"].get_value<int>();
|
||||
}
|
||||
}
|
||||
|
||||
void Player::readCollisionBlock(const fkyaml::node& yaml, const std::string& yaml_path) {
|
||||
@@ -1462,6 +1470,16 @@ void Player::render() {
|
||||
if (CLIP_HOLE) { Rendering::popClip(); }
|
||||
}
|
||||
|
||||
auto Player::getLightCenter() const -> SDL_FPoint {
|
||||
// Sprite top-left = (pos_.x, pos_.y). El render desplaça verticalment
|
||||
// `jump_z_` píxels durant el salt; aplicar el mateix offset aquí fa
|
||||
// que la llum "salti" amb el jugador en lloc de quedar-se al sòl.
|
||||
return {
|
||||
.x = getPosX() + (static_cast<float>(sprite_w) * 0.5F),
|
||||
.y = getPosY() - jump_z_ + (static_cast<float>(sprite_h) * 0.5F),
|
||||
};
|
||||
}
|
||||
|
||||
void Player::renderShadow() const {
|
||||
// Sense salt actiu, no hi ha sombra: això simplifica els callsites,
|
||||
// que poden cridar `renderShadow` per a tots els jugadors sense
|
||||
|
||||
Reference in new issue
Block a user