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

Method update

examples/example.cc:94–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92 explicit SpawnSystem(sf::RenderTarget &target, int count) : size(target.getSize()), count(count) {}
93
94 void update(ex::EntityManager &es, ex::EventManager &events, ex::TimeDelta dt) override {
95 int c = 0;
96 ex::ComponentHandle<Collideable> collideable;
97 for (ex::Entity entity : es.entities_with_components(collideable)) c++;
98
99 for (int i = 0; i < count - c; i++) {
100 ex::Entity entity = es.create();
101
102 // Mark as collideable (explosion particles will not be collideable).
103 collideable = entity.assign<Collideable>(r(10, 5));
104
105 // "Physical" attributes.
106 entity.assign<Body>(
107 sf::Vector2f(r(size.x), r(size.y)),
108 sf::Vector2f(r(100, -50), r(100, -50)));
109
110 // Shape to apply to entity.
111 std::unique_ptr<sf::Shape> shape(new sf::CircleShape(collideable->radius));
112 shape->setFillColor(sf::Color(r(128, 127), r(128, 127), r(128, 127)));
113 shape->setOrigin(collideable->radius, collideable->radius);
114 entity.assign<Renderable>(std::move(shape));
115 }
116 }
117
118private:
119 sf::Vector2u size;

Callers

nothing calls this directly

Calls 3

rFunction · 0.85
createMethod · 0.45

Tested by

no test coverage detected