| 139 | explicit BounceSystem(sf::RenderTarget &target) : size(target.getSize()) {} |
| 140 | |
| 141 | void update(ex::EntityManager &es, ex::EventManager &events, ex::TimeDelta dt) override { |
| 142 | ex::ComponentHandle<Body> body; |
| 143 | for (ex::Entity entity : es.entities_with_components(body)) { |
| 144 | if (body->position.x + body->direction.x < 0 || |
| 145 | body->position.x + body->direction.x >= size.x) |
| 146 | body->direction.x = -body->direction.x; |
| 147 | if (body->position.y + body->direction.y < 0 || |
| 148 | body->position.y + body->direction.y >= size.y) |
| 149 | body->direction.y = -body->direction.y; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | private: |
| 154 | sf::Vector2u size; |
nothing calls this directly
no test coverage detected