From 947d29aa374b9b5f5c581120ce5a4e7a32d0c981 Mon Sep 17 00:00:00 2001 From: Alec Thomas Date: Mon, 1 Apr 2013 11:51:29 -0400 Subject: Allow shared_ptr implementation to be selected. Fixes #6. --- README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 36f93fa..bc7248d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # EntityX - A fast, type-safe C++ Entity-Component system +[![Build Status](https://travis-ci.org/alecthomas/entityx.png)](https://travis-ci.org/alecthomas/entityx) + Entity-Component (EC) systems are a form of decomposition that completely decouples entity logic and data from the entity "objects" themselves. The [Evolve your Hierarchy](http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/) article provides a solid overview of EC systems and why you should use them. EntityX is an EC system that uses C++11 features to provide type-safe component management, event delivery, etc. It was built during the creation of a 2D space shooter. @@ -76,7 +78,7 @@ entity.assign(1.0f, 2.0f); You can also assign existing instances of components: ```c++ -boost::shared_ptr position = boost::make_shared(1.0f, 2.0f); +entityx::shared_ptr position = entityx::make_shared(1.0f, 2.0f); entity.assign(position); ``` @@ -86,8 +88,8 @@ To query all entities with a set of components assigned, use ``EntityManager::en ```c++ for (auto entity : entities.entities_with_components()) { - boost::shared_ptr position = entity.component(); - boost::shared_ptr direction = entity.component(); + entityx::shared_ptr position = entity.component(); + entityx::shared_ptr direction = entity.component(); // Do things with entity, position and direction. } @@ -96,7 +98,7 @@ for (auto entity : entities.entities_with_components()) { To retrieve a component associated with an entity use ``Entity::component()``: ```c++ -boost::shared_ptr position = entity.component(); +entityx::shared_ptr position = entity.component(); if (position) { // Do stuff with position } @@ -117,8 +119,8 @@ A basic movement system might be implemented with something like the following: struct MovementSystem : public System { void update(EntityManager &es, EventManager &events, double dt) override { for (auto entity : es.entities_with_components()) { - boost::shared_ptr position = entity.component(); - boost::shared_ptr direction = entity.component(); + entityx::shared_ptr position = entity.component(); + entityx::shared_ptr direction = entity.component(); position->x += direction->x * dt; position->y += direction->y * dt; @@ -154,7 +156,7 @@ Next we implement our collision system, which emits ``Collision`` objects via an class CollisionSystem : public System { public: void update(EntityManager &es, EventManager &events, double dt) override { - boost::shared_ptr left_position, right_position; + entityx::shared_ptr left_position, right_position; for (auto left_entity : es.entities_with_components()) { for (auto right_entity : es.entities_with_components()) { if (collide(left_position, right_position)) { @@ -192,7 +194,7 @@ Several events are emitted by EntityX itself: - `Entity entity` - Entity about to be destroyed. - `ComponentAddedEvent` - emitted when a new component is added to an entity. - `Entity entity` - Entity that component was added to. - - `boost::shared_ptr component` - The component added. + - `entityx::shared_ptr component` - The component added. #### Implementation notes -- cgit v1.2.3