# HG changeset patch # User Steve Losh # Date 1482508232 18000 # Node ID f3fc28996523c704df2f90c66cd9286d9263c58d # Parent 00c5f966ddac68251785c9e0ebf50e7742163a4e beast: Update site. diff -r 00c5f966ddac -r f3fc28996523 beast/index.html --- a/beast/index.html Fri Dec 16 13:20:20 2016 -0500 +++ b/beast/index.html Fri Dec 23 10:50:32 2016 -0500 @@ -16,7 +16,7 @@ Lisp. It's a thin layer of sugar over CLOS that makes it easy to write flexible objects for video games.

Beast can be installed with Quicklisp:

-
(ql:quickload :beast)
+
(ql:quickload :beast)
 
diff -r 00c5f966ddac -r f3fc28996523 beast/overview/index.html --- a/beast/overview/index.html Fri Dec 16 13:20:20 2016 -0500 +++ b/beast/overview/index.html Fri Dec 23 10:50:32 2016 -0500 @@ -20,12 +20,13 @@
  • http://en.wikipedia.org/wiki/Entity_component_system
  • http://www.gamedev.net/page/resources/_/technical/game-programming/understanding-component-entity-systems-r3013
  • -

    There are a couple of ECS libraries for Common Lisp already:

    +

    There were a couple of ECS libraries for Common Lisp already:

    -

    Both of these favor composition over inheritance -- game objects (entities) +

    Which were both superseded by net.axity.common-lisp.gamedev.ecs.

    +

    All of these favor composition over inheritance -- game objects (entities) contain various components, but they don't inherit from components.

    Beast takes the opposite approach, favoring (restricted) inheritance over composition.

    @@ -33,7 +34,7 @@ a little bit less in this crazy world. Aspects are essentially mixins, with some sugar for defining them and running systems over them:

    -
    (define-aspect throwable accuracy damage)
    +
    (define-aspect throwable accuracy damage)
     (define-aspect edible nutrition-value)
     
     (define-entity dart (throwable))
    diff -r 00c5f966ddac -r f3fc28996523 beast/reference/index.html
    --- a/beast/reference/index.html	Fri Dec 16 13:20:20 2016 -0500
    +++ b/beast/reference/index.html	Fri Dec 23 10:50:32 2016 -0500
    @@ -35,7 +35,7 @@
     

    Package BEAST

    CLEAR-ENTITIES (function)

    -
    (CLEAR-ENTITIES)
    +
    (CLEAR-ENTITIES)
     
    @@ -43,7 +43,7 @@

    destroy-entity will be called for each entity.

    Returns a list of all the destroyed entites.

    CREATE-ENTITY (function)

    -
    (CREATE-ENTITY CLASS &REST INITARGS)
    +
    (CREATE-ENTITY CLASS &REST INITARGS)
     
    @@ -52,7 +52,7 @@

    The entity-created generic function will be called just before returning the entity.

    DEFINE-ASPECT (macro)

    -
    (DEFINE-ASPECT NAME &REST FIELDS)
    +
    (DEFINE-ASPECT NAME &REST FIELDS)
     
    @@ -65,7 +65,7 @@ the slot names. :initarg and :accessor slot options will also be automatically generated.

    Example:

    -
    (define-aspect edible
    +
    (define-aspect edible
       energy
       (taste :initform nil))
     =>
    @@ -79,7 +79,7 @@
     
     
     

    DEFINE-ENTITY (macro)

    -
    (DEFINE-ENTITY NAME ASPECTS &REST SLOTS)
    +
    (DEFINE-ENTITY NAME ASPECTS &REST SLOTS)
     
    @@ -88,7 +88,7 @@

    aspects should be a list of the aspects this entity should inherit from.

    slots can be zero or more extra CLOS slot definitions.

    Examples:

    -
    (define-entity potion (drinkable))
    +
    (define-entity potion (drinkable))
     
     (define-entity cheese (edible visible)
       (flavor :accessor cheese-flavor :initarg :flavor))
    @@ -96,7 +96,7 @@
     
     
     

    DEFINE-SYSTEM (macro)

    -
    (DEFINE-SYSTEM NAME-AND-OPTIONS
    +
    (DEFINE-SYSTEM NAME-AND-OPTIONS
         ARGLIST
       &BODY
       BODY)
    @@ -121,7 +121,7 @@
         entity.  Defaults to nil.
     
     

    Examples:

    -
    (define-system age ((entity lifetime))
    +
    (define-system age ((entity lifetime))
       (when (> (incf (lifetime/age entity))
                (lifetime/lifespan entity))
         (destroy-entity entity)))
    @@ -129,7 +129,7 @@
     
     
     

    DESTROY-ENTITY (function)

    -
    (DESTROY-ENTITY ENTITY)
    +
    (DESTROY-ENTITY ENTITY)
     
    @@ -139,7 +139,7 @@

    ENTITY (class)

    A single entity in the game world.

    ENTITY-CREATED (generic function)

    -
    (ENTITY-CREATED ENTITY)
    +
    (ENTITY-CREATED ENTITY)
     
    @@ -147,7 +147,7 @@

    The default method does nothing, but users can implement their own auxillary methods to run code when entities are created.

    ENTITY-DESTROYED (generic function)

    -
    (ENTITY-DESTROYED ENTITY)
    +
    (ENTITY-DESTROYED ENTITY)
     
    @@ -155,7 +155,7 @@

    The default method does nothing, but users can implement their own auxillary methods to run code when entities are destroyed.

    MAP-ENTITIES (function)

    -
    (MAP-ENTITIES FUNCTION &OPTIONAL (TYPE 'ENTITY))
    +
    (MAP-ENTITIES FUNCTION &OPTIONAL (TYPE 'ENTITY))
     
    diff -r 00c5f966ddac -r f3fc28996523 beast/usage/index.html --- a/beast/usage/index.html Fri Dec 16 13:20:20 2016 -0500 +++ b/beast/usage/index.html Fri Dec 23 10:50:32 2016 -0500 @@ -37,7 +37,7 @@ examples could be things like: location, moveable, visible, edible, sentient.

    Defining Aspects

    To define an aspect you use define-aspect:

    -
    (define-aspect location x y)
    +
    (define-aspect location x y)
     (define-aspect edible nutrition-value)
     
    @@ -46,13 +46,13 @@

    The names of aspect slots will be have the aspect name prepended to them with a slash to avoid clashing between aspects, and the initargs and accessors will be added for you. So for example, this:

    -
    (define-aspect inspectable text)
    +
    (define-aspect inspectable text)
     (define-aspect readable text)
     

    Would macroexpand into something roughly like:

    -
    (defclass inspectable ()
    +
    (defclass inspectable ()
       ((inspectable/text :initarg :inspectable/text
                          :accessor inspectable/text)))
     
    @@ -66,7 +66,7 @@
     

    You can include extra slot options when defining an aspect's slots, and they'll be passed along to the defclass. This is especially handy for :initform and :type.

    -
    (define-aspect container
    +
    (define-aspect container
       (contents :initform nil))
     
     (define-aspect throwable
    @@ -81,7 +81,7 @@
     

    When you define an aspect named foo Beast also defines a foo? predicate that returns (typep object 'foo), which comes in handy when using higher-order functions:

    -
    (defun whats-for-dinner? ()
    +
    (defun whats-for-dinner? ()
       (remove-if-not #'edible? (container/contents *fridge*)))
     
    @@ -91,7 +91,7 @@ them together.

    Defining Entities

    You define entity classes using define-entity:

    -
    (define-entity dart (throwable))
    +
    (define-entity dart (throwable))
     (define-entity bread (edible))
     (define-entity pie (edible throwable))
     (define-entity icebox (container))
    @@ -100,7 +100,7 @@
     
     

    The resulting classes will inherit from entity and each of the aspects (in order). This example would expand (roughly) into:

    -
    (defclass dart (entity throwable) ())
    +
    (defclass dart (entity throwable) ())
     (defun dart? (object) (typep object 'dart))
     
     (defclass bread (entity edible) ())
    @@ -117,7 +117,7 @@
     

    Entity Slot Definitions

    You can also specify slot definitions at the entity level, and they'll be passed along to defclass:

    -
    (define-entity cheese (edible)
    +
    (define-entity cheese (edible)
       (variety :type (member :swiss :cheddar :feta)
                :initarg :variety
                :reader :cheese-variety))
    @@ -130,7 +130,7 @@
     

    Creating and Destroying Entities

    After you've defined your entity classes you can can create some entities using create-entity:

    -
    (defparameter *my-fridge* (create-entity 'icebox))
    +
    (defparameter *my-fridge* (create-entity 'icebox))
     
     (dotimes (i 30)
       (push (create-entity 'cheese
    @@ -150,7 +150,7 @@
     

    Beast also defines two generic functions called entity-created and entity-destroyed which don't do anything by default, but are there for you to add methods on if you want. For example:

    -
    (define-aspect location x y)
    +
    (define-aspect location x y)
     
     (defvar *world* (make-array (100 100) :initial-element nil))
     
    @@ -169,7 +169,7 @@
     

    A system is essentially a function that takes an entity as an argument with zero or more aspects as type specifiers. When you run a system the function will be run on every entity that meet the requirements. For example:

    -
    ; No specifiers, this just runs on every entity.
    +
    ; No specifiers, this just runs on every entity.
     (define-system log-all-entities (entity)
       (print entity))
     
    @@ -189,7 +189,7 @@
     
     

    Systems with more than one argument are currently supported, but should be considered experimental. The API may change in the future.

    -
    ; Run on all PAIRS of entities that have the appropriate aspects.
    +
    ; Run on all PAIRS of entities that have the appropriate aspects.
     (define-system detect-collisions ((e1 location collidable)
                                       (e2 location collidable))
       ; ...
    @@ -199,7 +199,7 @@
     
     

    define-system defines a function with the same name as the system, and a run-... function that will do the actual running for you:

    -
    (define-system log-all-entities (entity)
    +
    (define-system log-all-entities (entity)
       (print entity))
     
     (run-log-all-entities)