From 70d2aef8ea1edd50df3050d503eda029fbc4d706 Mon Sep 17 00:00:00 2001 From: Alec Thomas Date: Tue, 4 Jun 2013 12:25:28 -0400 Subject: Update documentation. Fixes #8. --- README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index ff1e8ef..2a0f22a 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,10 @@ Entities are simply 64-bit numeric identifiers with which components are associa Creating an entity is as simple as: ```c++ -EventManager events; -EntityManager entities(events); +entityx::shared_ptr events = EventManager::make(); +entityx::shared_ptr entities = EntityManager::make(events); -Entity entity = entities.create(); +Entity entity = entities->create(); ``` And destroying an entity is done with: @@ -87,7 +87,7 @@ entity.assign(position); To query all entities with a set of components assigned, use ``EntityManager::entities_with_components()``. This method will return only those entities that have *all* of the specified components associated with them, assigning each component pointer to the corresponding component instance: ```c++ -for (auto entity : entities.entities_with_components()) { +for (auto entity : entities->entities_with_components()) { entityx::shared_ptr position = entity.component(); entityx::shared_ptr direction = entity.component(); @@ -117,8 +117,8 @@ A basic movement system might be implemented with something like the following: ```c++ struct MovementSystem : public System { - void update(EntityManager &es, EventManager &events, double dt) override { - for (auto entity : es.entities_with_components()) { + void update(entityx::shared_ptr es, entityx::shared_ptr events, double dt) override { + for (auto entity : es->entities_with_components()) { entityx::shared_ptr position = entity.component(); entityx::shared_ptr direction = entity.component(); @@ -155,7 +155,7 @@ Next we implement our collision system, which emits ``Collision`` objects via an ```c++ class CollisionSystem : public System { public: - void update(EntityManager &es, EventManager &events, double dt) override { + void update(entityx::shared_ptr es, entityx::shared_ptr events, double dt) override { entityx::shared_ptr left_position, right_position; for (auto left_entity : es.entities_with_components()) { for (auto right_entity : es.entities_with_components()) { @@ -213,23 +213,23 @@ To use it, subclass `Manager` and implement `configure()`, `initialize()` and `u class GameManager : public Manager { protected: void configure() { - system_manager.add(); - system_manager.add(); - system_manager.add(); + system_manager->add(); + system_manager->add(); + system_manager->add(); } void initialize() { // Create some entities in random locations heading in random directions for (int i = 0; i < 100; ++i) { - Entity entity = entity_manager.create(); + Entity entity = entity_manager->create(); entity.assign(rand() % 100, rand() % 100); entity.assign((rand() % 10) - 5, (rand() % 10) - 5); } } void update(double dt) { - system_manager.update(dt); - system_manager.update(dt); + system_manager->update(dt); + system_manager->update(dt); } }; ``` -- cgit v1.2.3