Entity-component-system for Clojure.

Build Status

1. Latest Release

1.1. Leiningen

Add this to your :dependencies in project.clj:

Clojars Project

2. Usage

TODO: Fill this in.

3. Examples

Official demos are here.

4. API Documentation

API documentation is here.

5. Changelog

Changes Since Version 2.0.0
  • Added validation to atom-world's query implementation. It doesn’t allow unknown (unreadable by currently running system) components to be queries anymore.

Changes Since Version 1.1.0
  • ITransactableWorld and transaction concept are removed.

    ;; A systems process used to call transaction!
    ;; to get an editable world:
      (fn [w dt]
        (transaction! w (fn [w] (set-component! w ...))))
    ;; Now process receives an editable world and can modify
    ;; the world directly:
    (fn [w dt]
      (set-component! w ...))
  • Components and systems are registered with worlds during initialization. Use clecs.world/world to create a new world.

    • clecs.backend.atom-world/make-world is removed. Use clecs.world/world with clecs.world.backend.atom-world/atom-world-factory instead:

      (world atom-world-factory
             {:components [(component ...)
                           (component ...)
                           (component ...)
              :initializer (fn [w] ...)
              :systems [(system ...)
                        (system ...)
    • ISystemManager is renamed as IWorld.

      Following functions are removed from this protocol:

      • remove-system!

      • set-system!

      • systems

  • world/set-component accepts entity-id and component type explicitly.

    ;; Old way:
      (def c (->SomeComponent eid x y))
      (world/set-component w c))
    ;; New way:
    (world/set-component w eid :my.ns/SomeComponent {:x x :y y})
  • world/set-component validates its input.

  • Queries are constructed using component type keywords instead of records:

    ;; Old way:
      (defrecord SomeComponent [eid])
      (def q (all SomeComponent)))
    ;; New way:
    (def q (all :my.ns/SomeComponent))
  • clecs.core/make-world is removed.

  • Following deprecated functions are removed:

    • clecs.component/component?

    • clecs.component/component-label

    • clecs.component/component-type?

    • clecs.component/defcomponent

  • Removed support for systems as functions.

  • Deprecated IComponent is removed.

Changes Since Version 1.0.0
  • Components are no longer records. The same API still works but since a java class is not generated anymore you are likely to get an error like:

    java.lang.ClassNotFoundException: java_path.to.YourComponent

    To solve this problem declare components in a :require instead of :import. (Examples: muhuk/clecs-examples@a965ab1 & muhuk/clecs-examples@22de34f)

  • Added suport for systems as maps. Assuming sys-fn is an old style system you can write a system as:

    {:process sys-fn}
Changes Since Version 0.2.0
  • Replaced function based queries with data driven queries. See clecs.query.

6. Previous Versions

7. See Also

8. License

Copyright © 2015 Atamert Ölçgen

This program is distributed under GNU GPL v3 license. See LICENSE file.