Tried to refactor for but #42 but nothing worked. I'll try later.
This commit is contained in:
parent
05fc9062a7
commit
a1c3f4df5a
5 changed files with 17 additions and 19 deletions
|
|
@ -95,14 +95,12 @@ void Raycaster::draw_pixel_buffer() {
|
|||
$view_texture.update((uint8_t *)$pixels.get(), {(unsigned int)$width, (unsigned int)$height}, {0, 0});
|
||||
}
|
||||
|
||||
|
||||
void Raycaster::apply_sprite_effect(shared_ptr<sf::Shader> effect, float width, float height) {
|
||||
effect->setUniform("u_time", $clock.getElapsedTime().asSeconds());
|
||||
sf::Vector2f u_resolution{width, height};
|
||||
effect->setUniform("u_resolution", u_resolution);
|
||||
}
|
||||
|
||||
|
||||
void Raycaster::sprite_casting(sf::RenderTarget &target) {
|
||||
auto& lights = $level.lights->lighting();
|
||||
auto world = $level.world;
|
||||
|
|
@ -192,17 +190,10 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) {
|
|||
sf::Vector2f position{x + origin.x * scale.x, y + origin.y * scale.y};
|
||||
sf::IntRect in_texture{ {tex_x, tex_y}, {tex_render_width, texture_height}};
|
||||
|
||||
animation::step_animation(*world, rec.entity, scale, position, in_texture);
|
||||
|
||||
sf_sprite->setOrigin(origin);
|
||||
sf_sprite->setScale(scale);
|
||||
sf_sprite->setTextureRect(in_texture);
|
||||
sf_sprite->setPosition(position);
|
||||
shared_ptr<sf::Shader> effect = System::sprite_effect(rec.entity);
|
||||
|
||||
float level = lights[sprite_pos.location.y][sprite_pos.location.x] * PERCENT;
|
||||
|
||||
shared_ptr<sf::Shader> effect = System::sprite_effect(rec.entity);
|
||||
|
||||
if(effect) {
|
||||
apply_sprite_effect(effect, sprite_width, sprite_height);
|
||||
} else {
|
||||
|
|
@ -211,6 +202,13 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) {
|
|||
effect->setUniform("darkness", level);
|
||||
}
|
||||
|
||||
animation::step_animation(*world, rec.entity, scale, position, in_texture);
|
||||
|
||||
sf_sprite->setOrigin(origin);
|
||||
sf_sprite->setScale(scale);
|
||||
sf_sprite->setTextureRect(in_texture);
|
||||
sf_sprite->setPosition(position);
|
||||
|
||||
target.draw(*sf_sprite, effect.get());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue