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

Method update

examples/example.cc:340–359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

338 }
339
340 void update(ex::EntityManager &es, ex::EventManager &events, ex::TimeDelta dt) override {
341 ex::ComponentHandle<Body> body;
342 ex::ComponentHandle<Renderable> renderable;
343 for (ex::Entity entity : es.entities_with_components(body, renderable)) {
344 renderable->shape->setPosition(body->position);
345 renderable->shape->setRotation(body->rotation);
346 target.draw(*renderable->shape.get());
347 }
348 last_update += dt;
349 frame_count++;
350 if (last_update >= 0.5) {
351 std::ostringstream out;
352 const double fps = frame_count / last_update;
353 out << es.size() << " entities (" << static_cast<int>(fps) << " fps)";
354 text.setString(out.str());
355 last_update = 0.0;
356 frame_count = 0.0;
357 }
358 target.draw(text);
359 }
360
361private:
362 double last_update = 0.0;

Callers

nothing calls this directly

Calls 3

getMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected