aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorAlec Thomas <alec@swapoff.org>2013-04-01 11:51:29 -0400
committerAlec Thomas <alec@swapoff.org>2013-04-02 17:50:58 -0400
commit947d29aa374b9b5f5c581120ce5a4e7a32d0c981 (patch)
tree9a22cf41b4db463ff17e964fe36e78e3219d46d9 /README.md
parente569dc47c9ff3c3118cb96427d3ec9a6aced98aa (diff)
Allow shared_ptr implementation to be selected.
Fixes #6.
Diffstat (limited to 'README.md')
-rw-r--r--README.md18
1 files changed, 10 insertions, 8 deletions
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<Position>(1.0f, 2.0f);
You can also assign existing instances of components:
```c++
-boost::shared_ptr<Position> position = boost::make_shared<Position>(1.0f, 2.0f);
+entityx::shared_ptr<Position> position = entityx::make_shared<Position>(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<Position, Direction>()) {
- boost::shared_ptr<Position> position = entity.component<Position>();
- boost::shared_ptr<Direction> direction = entity.component<Direction>();
+ entityx::shared_ptr<Position> position = entity.component<Position>();
+ entityx::shared_ptr<Direction> direction = entity.component<Direction>();
// Do things with entity, position and direction.
}
@@ -96,7 +98,7 @@ for (auto entity : entities.entities_with_components<Position, Direction>()) {
To retrieve a component associated with an entity use ``Entity::component<C>()``:
```c++
-boost::shared_ptr<Position> position = entity.component<Position>();
+entityx::shared_ptr<Position> position = entity.component<Position>();
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<MovementSystem> {
void update(EntityManager &es, EventManager &events, double dt) override {
for (auto entity : es.entities_with_components<Position, Direction>()) {
- boost::shared_ptr<Position> position = entity.component<Position>();
- boost::shared_ptr<Direction> direction = entity.component<Direction>();
+ entityx::shared_ptr<Position> position = entity.component<Position>();
+ entityx::shared_ptr<Direction> direction = entity.component<Direction>();
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<CollisionSystem> {
public:
void update(EntityManager &es, EventManager &events, double dt) override {
- boost::shared_ptr<Position> left_position, right_position;
+ entityx::shared_ptr<Position> left_position, right_position;
for (auto left_entity : es.entities_with_components<Position>()) {
for (auto right_entity : es.entities_with_components<Position>()) {
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<T>` - emitted when a new component is added to an entity.
- `Entity entity` - Entity that component was added to.
- - `boost::shared_ptr<T> component` - The component added.
+ - `entityx::shared_ptr<T> component` - The component added.
#### Implementation notes