MCPcopy Create free account
hub / github.com/alecthomas/entityx / update

Method update

examples/example.cc:141–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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
153private:
154 sf::Vector2u size;

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected