diff options
| author | Rubén Beltrán del Río <ben@nsovocal.com> | 2018-04-21 17:45:38 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-21 17:45:38 -0500 |
| commit | 493ec31cb19b4211c703762d14a4e6232c4c2143 (patch) | |
| tree | c0c33fab8f2fb040dc714ab76f0eb5479f001b2e /doc | |
| parent | 0616b3f00653c66b5e34814653e33413b9ec034e (diff) | |
Physics Engine (#4)
* Add matter-js as a dependency
* Add body component
* Fix renderable node doc
* Add the physics node type
* Correct typo in physics enabled node types
* Update docs on render system
* Add physics system
* Update changelog
* Add physics engine to main app
* Tweak the gravity of the world
* Add body to sumo factory
* Add angle component
* Add angle to entity
* Add angle to the nodes
* Pass angle between systems
* Set default angle to 0
* Split systems and nodes
* Fix indentaion in physics world control
* Add third sumo entity
* Adjust values for constriants and physics
* Correct docs in new nodes
* Update built-in docs
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/README.md | 584 |
1 files changed, 584 insertions, 0 deletions
diff --git a/doc/README.md b/doc/README.md index 2d79f30..2d367a5 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,3 +1,268 @@ +## Classes + +<dl> +<dt><a href="#AngleComponent">AngleComponent</a> ⇐ <code>external:Serpentity.Component</code></dt> +<dd></dd> +<dt><a href="#BodyComponent">BodyComponent</a> ⇐ <code>external:Serpentity.Component</code></dt> +<dd></dd> +<dt><a href="#CoupledEntitiesComponent">CoupledEntitiesComponent</a> ⇐ <code>external:Serpentity.Component</code></dt> +<dd></dd> +<dt><a href="#PixiContainerComponent">PixiContainerComponent</a> ⇐ <code>external:Serpentity.Component</code></dt> +<dd></dd> +<dt><a href="#PhysicalWithAttributesNode">PhysicalWithAttributesNode</a> ⇐ <code>external:Serpentity.Node</code></dt> +<dd></dd> +<dt><a href="#PhysicalNode">PhysicalNode</a> ⇐ <code>external:Serpentity.Node</code></dt> +<dd></dd> +<dt><a href="#RenderableCoupleNode">RenderableCoupleNode</a> ⇐ <code>external:Serpentity.Node</code></dt> +<dd></dd> +<dt><a href="#RenderableWithAttributesNode">RenderableWithAttributesNode</a> ⇐ <code>external:Serpentity.Node</code></dt> +<dd></dd> +<dt><a href="#RenderableNode">RenderableNode</a> ⇐ <code>external:Serpentity.Node</code></dt> +<dd></dd> +<dt><a href="#Sumo">Sumo</a></dt> +<dd></dd> +<dt><a href="#AttributesToRenderableSystem">AttributesToRenderableSystem</a> ⇐ <code>external:Serpentity.System</code></dt> +<dd></dd> +<dt><a href="#CreateCouplingLineSystem">CreateCouplingLineSystem</a> ⇐ <code>external:Serpentity.System</code></dt> +<dd></dd> +<dt><a href="#PhysicsToAttributesSystem">PhysicsToAttributesSystem</a> ⇐ <code>external:Serpentity.System</code></dt> +<dd></dd> +<dt><a href="#PhysicsWorldControlSystem">PhysicsWorldControlSystem</a> ⇐ <code>external:Serpentity.System</code></dt> +<dd></dd> +<dt><a href="#RenderSystem">RenderSystem</a> ⇐ <code>external:Serpentity.System</code></dt> +<dd></dd> +</dl> + +## Members + +<dl> +<dt><a href="#PixiFactory">PixiFactory</a> : <code>object</code></dt> +<dd><p>Factory object that contains many methods to create prefab pixi +objects</p> +</dd> +<dt><a href="#SumoFactory">SumoFactory</a> : <code>object</code></dt> +<dd><p>Factory object that contains many methods to create prefab entities.</p> +</dd> +</dl> + +<a name="AngleComponent"></a> + +## AngleComponent ⇐ <code>external:Serpentity.Component</code> +**Kind**: global class +**Extends**: <code>external:Serpentity.Component</code> +<a name="new_AngleComponent_new"></a> + +### new AngleComponent(config) +Component that stores an angle + + +| Param | Type | Description | +| --- | --- | --- | +| config | <code>object</code> | a configuration object to extend. | + +<a name="BodyComponent"></a> + +## BodyComponent ⇐ <code>external:Serpentity.Component</code> +**Kind**: global class +**Extends**: <code>external:Serpentity.Component</code> +<a name="new_BodyComponent_new"></a> + +### new BodyComponent(config) +Component that stores a body for physics calculation + + +| Param | Type | Description | +| --- | --- | --- | +| config | <code>object</code> | a configuration object to extend. | + +<a name="CoupledEntitiesComponent"></a> + +## CoupledEntitiesComponent ⇐ <code>external:Serpentity.Component</code> +**Kind**: global class +**Extends**: <code>external:Serpentity.Component</code> +<a name="new_CoupledEntitiesComponent_new"></a> + +### new CoupledEntitiesComponent(config) +Component that stores a number of entities coupled to this one. + + +| Param | Type | Description | +| --- | --- | --- | +| config | <code>object</code> | a configuration object to extend. | + +<a name="PixiContainerComponent"></a> + +## PixiContainerComponent ⇐ <code>external:Serpentity.Component</code> +**Kind**: global class +**Extends**: <code>external:Serpentity.Component</code> + +* [PixiContainerComponent](#PixiContainerComponent) ⇐ <code>external:Serpentity.Component</code> + * [new PixiContainerComponent(config)](#new_PixiContainerComponent_new) + * [.container](#PixiContainerComponent+container) + +<a name="new_PixiContainerComponent_new"></a> + +### new PixiContainerComponent(config) +Component that stores a pixi container + + +| Param | Type | Description | +| --- | --- | --- | +| config | <code>object</code> | a configuration object to extend. | + +<a name="PixiContainerComponent+container"></a> + +### pixiContainerComponent.container +The properthy that holds the pixi container + +**Kind**: instance property of [<code>PixiContainerComponent</code>](#PixiContainerComponent) +**Properties** + +| Name | Type | +| --- | --- | +| container | <code>external:PixiJs.Container</code> | + +<a name="PhysicalWithAttributesNode"></a> + +## PhysicalWithAttributesNode ⇐ <code>external:Serpentity.Node</code> +**Kind**: global class +**Extends**: <code>external:Serpentity.Node</code> + +* [PhysicalWithAttributesNode](#PhysicalWithAttributesNode) ⇐ <code>external:Serpentity.Node</code> + * [new PhysicalWithAttributesNode()](#new_PhysicalWithAttributesNode_new) + * [.types](#PhysicalWithAttributesNode.types) + +<a name="new_PhysicalWithAttributesNode_new"></a> + +### new PhysicalWithAttributesNode() +Node identifying an entity that can interact with physics and has +components updated from its values + +<a name="PhysicalWithAttributesNode.types"></a> + +### PhysicalWithAttributesNode.types +Holds the types that are used to identify an entity with a physics +object and external attributes + +**Kind**: static property of [<code>PhysicalWithAttributesNode</code>](#PhysicalWithAttributesNode) +**Properties** + +| Name | Type | +| --- | --- | +| types | <code>object</code> | + +<a name="PhysicalNode"></a> + +## PhysicalNode ⇐ <code>external:Serpentity.Node</code> +**Kind**: global class +**Extends**: <code>external:Serpentity.Node</code> + +* [PhysicalNode](#PhysicalNode) ⇐ <code>external:Serpentity.Node</code> + * [new PhysicalNode()](#new_PhysicalNode_new) + * [.types](#PhysicalNode.types) + +<a name="new_PhysicalNode_new"></a> + +### new PhysicalNode() +Node identifying an entity that can interact with physics + +<a name="PhysicalNode.types"></a> + +### PhysicalNode.types +Holds the types that are used to identify an entity with a physical +body + +**Kind**: static property of [<code>PhysicalNode</code>](#PhysicalNode) +**Properties** + +| Name | Type | +| --- | --- | +| types | <code>object</code> | + +<a name="RenderableCoupleNode"></a> + +## RenderableCoupleNode ⇐ <code>external:Serpentity.Node</code> +**Kind**: global class +**Extends**: <code>external:Serpentity.Node</code> + +* [RenderableCoupleNode](#RenderableCoupleNode) ⇐ <code>external:Serpentity.Node</code> + * [new RenderableCoupleNode()](#new_RenderableCoupleNode_new) + * [.types](#RenderableCoupleNode.types) + +<a name="new_RenderableCoupleNode_new"></a> + +### new RenderableCoupleNode() +Node identifying an entity that has coupled entities and can be +rendered + +<a name="RenderableCoupleNode.types"></a> + +### RenderableCoupleNode.types +Holds the types that are used to identify a renderable couple + +**Kind**: static property of [<code>RenderableCoupleNode</code>](#RenderableCoupleNode) +**Properties** + +| Name | Type | +| --- | --- | +| types | <code>object</code> | + +<a name="RenderableWithAttributesNode"></a> + +## RenderableWithAttributesNode ⇐ <code>external:Serpentity.Node</code> +**Kind**: global class +**Extends**: <code>external:Serpentity.Node</code> + +* [RenderableWithAttributesNode](#RenderableWithAttributesNode) ⇐ <code>external:Serpentity.Node</code> + * [new RenderableWithAttributesNode()](#new_RenderableWithAttributesNode_new) + * [.types](#RenderableWithAttributesNode.types) + +<a name="new_RenderableWithAttributesNode_new"></a> + +### new RenderableWithAttributesNode() +Node identifying a renderable entity, should have position and a +symbol to render + +<a name="RenderableWithAttributesNode.types"></a> + +### RenderableWithAttributesNode.types +Holds the types that are used to identify a renderable with external +attributes + +**Kind**: static property of [<code>RenderableWithAttributesNode</code>](#RenderableWithAttributesNode) +**Properties** + +| Name | Type | +| --- | --- | +| types | <code>object</code> | + +<a name="RenderableNode"></a> + +## RenderableNode ⇐ <code>external:Serpentity.Node</code> +**Kind**: global class +**Extends**: <code>external:Serpentity.Node</code> + +* [RenderableNode](#RenderableNode) ⇐ <code>external:Serpentity.Node</code> + * [new RenderableNode()](#new_RenderableNode_new) + * [.types](#RenderableNode.types) + +<a name="new_RenderableNode_new"></a> + +### new RenderableNode() +Node identifying a renderable entity, should have a pixi renderable + +<a name="RenderableNode.types"></a> + +### RenderableNode.types +Holds the types that are used to identify a renderable entity + +**Kind**: static property of [<code>RenderableNode</code>](#RenderableNode) +**Properties** + +| Name | Type | +| --- | --- | +| types | <code>object</code> | + <a name="Sumo"></a> ## Sumo @@ -40,3 +305,322 @@ live until after you stop and start the loop) Pauses the loop **Kind**: instance method of [<code>Sumo</code>](#Sumo) +<a name="AttributesToRenderableSystem"></a> + +## AttributesToRenderableSystem ⇐ <code>external:Serpentity.System</code> +**Kind**: global class +**Extends**: <code>external:Serpentity.System</code> + +* [AttributesToRenderableSystem](#AttributesToRenderableSystem) ⇐ <code>external:Serpentity.System</code> + * [new AttributesToRenderableSystem(config)](#new_AttributesToRenderableSystem_new) + * [.added(engine)](#AttributesToRenderableSystem+added) + * [.removed()](#AttributesToRenderableSystem+removed) + * [.update(currentFrameDuration)](#AttributesToRenderableSystem+update) + +<a name="new_AttributesToRenderableSystem_new"></a> + +### new AttributesToRenderableSystem(config) +Updates the renderables based on their attribuets + + +| Param | Type | Description | +| --- | --- | --- | +| config | <code>object</code> | a configuration object to extend. | + +<a name="AttributesToRenderableSystem+added"></a> + +### attributesToRenderableSystem.added(engine) +Initializes system when added. Requests renderable nodes and +attaches to event listeners to add / remove them to pixi stage + +**Kind**: instance method of [<code>AttributesToRenderableSystem</code>](#AttributesToRenderableSystem) + +| Param | Type | Description | +| --- | --- | --- | +| engine | <code>external:Serpentity.Engine</code> | the serpentity engine to which we are getting added | + +<a name="AttributesToRenderableSystem+removed"></a> + +### attributesToRenderableSystem.removed() +Clears system resources when removed. + +**Kind**: instance method of [<code>AttributesToRenderableSystem</code>](#AttributesToRenderableSystem) +<a name="AttributesToRenderableSystem+update"></a> + +### attributesToRenderableSystem.update(currentFrameDuration) +Runs on every update of the loop. Updates the graphics so they're +rendered correctly + +**Kind**: instance method of [<code>AttributesToRenderableSystem</code>](#AttributesToRenderableSystem) + +| Param | Type | Description | +| --- | --- | --- | +| currentFrameDuration | <code>Number</code> | the duration of the current frame | + +<a name="CreateCouplingLineSystem"></a> + +## CreateCouplingLineSystem ⇐ <code>external:Serpentity.System</code> +**Kind**: global class +**Extends**: <code>external:Serpentity.System</code> + +* [CreateCouplingLineSystem](#CreateCouplingLineSystem) ⇐ <code>external:Serpentity.System</code> + * [new CreateCouplingLineSystem(config)](#new_CreateCouplingLineSystem_new) + * [.added(engine)](#CreateCouplingLineSystem+added) + * [.removed()](#CreateCouplingLineSystem+removed) + * [.update(currentFrameDuration)](#CreateCouplingLineSystem+update) + +<a name="new_CreateCouplingLineSystem_new"></a> + +### new CreateCouplingLineSystem(config) +Renders renderable objects using pixi + + +| Param | Type | Description | +| --- | --- | --- | +| config | <code>object</code> | a configuration object to extend. | + +<a name="CreateCouplingLineSystem+added"></a> + +### createCouplingLineSystem.added(engine) +Initializes system when added. Requests renderable nodes and + +**Kind**: instance method of [<code>CreateCouplingLineSystem</code>](#CreateCouplingLineSystem) + +| Param | Type | Description | +| --- | --- | --- | +| engine | <code>external:Serpentity.Engine</code> | the serpentity engine to which we are getting added | + +<a name="CreateCouplingLineSystem+removed"></a> + +### createCouplingLineSystem.removed() +Clears system resources when removed. + +**Kind**: instance method of [<code>CreateCouplingLineSystem</code>](#CreateCouplingLineSystem) +<a name="CreateCouplingLineSystem+update"></a> + +### createCouplingLineSystem.update(currentFrameDuration) +Runs on every update of the loop. Does nothing. + +**Kind**: instance method of [<code>CreateCouplingLineSystem</code>](#CreateCouplingLineSystem) + +| Param | Type | Description | +| --- | --- | --- | +| currentFrameDuration | <code>Number</code> | the duration of the current frame | + +<a name="PhysicsToAttributesSystem"></a> + +## PhysicsToAttributesSystem ⇐ <code>external:Serpentity.System</code> +**Kind**: global class +**Extends**: <code>external:Serpentity.System</code> + +* [PhysicsToAttributesSystem](#PhysicsToAttributesSystem) ⇐ <code>external:Serpentity.System</code> + * [new PhysicsToAttributesSystem(config)](#new_PhysicsToAttributesSystem_new) + * [.added(engine)](#PhysicsToAttributesSystem+added) + * [.removed()](#PhysicsToAttributesSystem+removed) + * [.update(currentFrameDuration)](#PhysicsToAttributesSystem+update) + +<a name="new_PhysicsToAttributesSystem_new"></a> + +### new PhysicsToAttributesSystem(config) +Distribuets physics data to the related components + + +| Param | Type | Description | +| --- | --- | --- | +| config | <code>object</code> | a configuration object to extend. | + +<a name="PhysicsToAttributesSystem+added"></a> + +### physicsToAttributesSystem.added(engine) +Initializes system when added. Requests physics nodes + +**Kind**: instance method of [<code>PhysicsToAttributesSystem</code>](#PhysicsToAttributesSystem) + +| Param | Type | Description | +| --- | --- | --- | +| engine | <code>external:Serpentity.Engine</code> | the serpentity engine to which we are getting added | + +<a name="PhysicsToAttributesSystem+removed"></a> + +### physicsToAttributesSystem.removed() +Clears system resources when removed. + +**Kind**: instance method of [<code>PhysicsToAttributesSystem</code>](#PhysicsToAttributesSystem) +<a name="PhysicsToAttributesSystem+update"></a> + +### physicsToAttributesSystem.update(currentFrameDuration) +Runs on every update of the loop. Updates the other components +based on physics + +**Kind**: instance method of [<code>PhysicsToAttributesSystem</code>](#PhysicsToAttributesSystem) + +| Param | Type | Description | +| --- | --- | --- | +| currentFrameDuration | <code>Number</code> | the duration of the current frame | + +<a name="PhysicsWorldControlSystem"></a> + +## PhysicsWorldControlSystem ⇐ <code>external:Serpentity.System</code> +**Kind**: global class +**Extends**: <code>external:Serpentity.System</code> + +* [PhysicsWorldControlSystem](#PhysicsWorldControlSystem) ⇐ <code>external:Serpentity.System</code> + * [new PhysicsWorldControlSystem(config)](#new_PhysicsWorldControlSystem_new) + * [.added(engine)](#PhysicsWorldControlSystem+added) + * [.removed()](#PhysicsWorldControlSystem+removed) + * [.update(currentFrameDuration)](#PhysicsWorldControlSystem+update) + +<a name="new_PhysicsWorldControlSystem_new"></a> + +### new PhysicsWorldControlSystem(config) +Adds and removes objects to the physics world and calls update + + +| Param | Type | Description | +| --- | --- | --- | +| config | <code>object</code> | a configuration object to extend. | + +<a name="PhysicsWorldControlSystem+added"></a> + +### physicsWorldControlSystem.added(engine) +Initializes system when added. Requests physics nodes and +attaches to event listeners to add / remove them to pixi stage + +**Kind**: instance method of [<code>PhysicsWorldControlSystem</code>](#PhysicsWorldControlSystem) + +| Param | Type | Description | +| --- | --- | --- | +| engine | <code>external:Serpentity.Engine</code> | the serpentity engine to which we are getting added | + +<a name="PhysicsWorldControlSystem+removed"></a> + +### physicsWorldControlSystem.removed() +Clears system resources when removed. + +**Kind**: instance method of [<code>PhysicsWorldControlSystem</code>](#PhysicsWorldControlSystem) +<a name="PhysicsWorldControlSystem+update"></a> + +### physicsWorldControlSystem.update(currentFrameDuration) +Runs on every update of the loop. Updates the physics + +**Kind**: instance method of [<code>PhysicsWorldControlSystem</code>](#PhysicsWorldControlSystem) + +| Param | Type | Description | +| --- | --- | --- | +| currentFrameDuration | <code>Number</code> | the duration of the current frame | + +<a name="RenderSystem"></a> + +## RenderSystem ⇐ <code>external:Serpentity.System</code> +**Kind**: global class +**Extends**: <code>external:Serpentity.System</code> + +* [RenderSystem](#RenderSystem) ⇐ <code>external:Serpentity.System</code> + * [new RenderSystem(config)](#new_RenderSystem_new) + * [.added(engine)](#RenderSystem+added) + * [.removed()](#RenderSystem+removed) + * [.update(currentFrameDuration)](#RenderSystem+update) + +<a name="new_RenderSystem_new"></a> + +### new RenderSystem(config) +Renders renderable objects using pixi + + +| Param | Type | Description | +| --- | --- | --- | +| config | <code>object</code> | a configuration object to extend. | + +<a name="RenderSystem+added"></a> + +### renderSystem.added(engine) +Initializes system when added. Requests renderable nodes and +attaches to event listeners to add / remove them to pixi stage + +**Kind**: instance method of [<code>RenderSystem</code>](#RenderSystem) + +| Param | Type | Description | +| --- | --- | --- | +| engine | <code>external:Serpentity.Engine</code> | the serpentity engine to which we are getting added | + +<a name="RenderSystem+removed"></a> + +### renderSystem.removed() +Clears system resources when removed. + +**Kind**: instance method of [<code>RenderSystem</code>](#RenderSystem) +<a name="RenderSystem+update"></a> + +### renderSystem.update(currentFrameDuration) +Runs on every update of the loop. Does nothing. + +**Kind**: instance method of [<code>RenderSystem</code>](#RenderSystem) + +| Param | Type | Description | +| --- | --- | --- | +| currentFrameDuration | <code>Number</code> | the duration of the current frame | + +<a name="PixiFactory"></a> + +## PixiFactory : <code>object</code> +Factory object that contains many methods to create prefab pixi +objects + +**Kind**: global variable + +* [PixiFactory](#PixiFactory) : <code>object</code> + * [.createSumo()](#PixiFactory.createSumo) ⇒ <code>external:CreateJs.Container</code> + * [.createEmptyGraphic()](#PixiFactory.createEmptyGraphic) ⇒ <code>external:CreateJs.Container</code> + +<a name="PixiFactory.createSumo"></a> + +### PixiFactory.createSumo() ⇒ <code>external:CreateJs.Container</code> +Creates a sumo container + +**Kind**: static method of [<code>PixiFactory</code>](#PixiFactory) +**Returns**: <code>external:CreateJs.Container</code> - the created container +<a name="PixiFactory.createEmptyGraphic"></a> + +### PixiFactory.createEmptyGraphic() ⇒ <code>external:CreateJs.Container</code> +Creates an empty graphic + +**Kind**: static method of [<code>PixiFactory</code>](#PixiFactory) +**Returns**: <code>external:CreateJs.Container</code> - the created container +<a name="SumoFactory"></a> + +## SumoFactory : <code>object</code> +Factory object that contains many methods to create prefab entities. + +**Kind**: global variable + +* [SumoFactory](#SumoFactory) : <code>object</code> + * [.createSumo([engine], [config])](#SumoFactory.createSumo) ⇒ <code>external:Serpentity.Entity</code> + * [.createRubberBand([engine], [config])](#SumoFactory.createRubberBand) ⇒ <code>external:Serpentity.Entity</code> + +<a name="SumoFactory.createSumo"></a> + +### SumoFactory.createSumo([engine], [config]) ⇒ <code>external:Serpentity.Entity</code> +Creates a sumo entity and adds it to the engine. Can override +position in the config object + +**Kind**: static method of [<code>SumoFactory</code>](#SumoFactory) +**Returns**: <code>external:Serpentity.Entity</code> - the created entity + +| Param | Type | Description | +| --- | --- | --- | +| [engine] | <code>external:Serpentity</code> | the serpentity engine to attach to. If not sent, it will not be attached. | +| [config] | <code>object</code> | the config to override the entity, accepts the key `position` as an object with an x and y property. | + +<a name="SumoFactory.createRubberBand"></a> + +### SumoFactory.createRubberBand([engine], [config]) ⇒ <code>external:Serpentity.Entity</code> +Creates a rubber band entity and adds it to the engine. + +**Kind**: static method of [<code>SumoFactory</code>](#SumoFactory) +**Returns**: <code>external:Serpentity.Entity</code> - the created entity + +| Param | Type | Description | +| --- | --- | --- | +| [engine] | <code>external:Serpentity</code> | the serpentity engine to attach to. If not sent, it will not be attached. | +| [config] | <code>object</code> | the config to override the entity, it must include entityA and entityB which will be tied by it. If they are not sent or don't have a physics body, this will throw. | + |