mirror of
https://github.com/bakpakin/tiny-ecs.git
synced 2026-07-22 07:56:52 -06:00
Docs commit.
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>tiny-ecs API</title>
|
||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>ldoc</h1>
|
||||
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Use_It">Use It </a></li>
|
||||
<li><a href="#Overview">Overview </a></li>
|
||||
<li><a href="#Example">Example </a></li>
|
||||
<li><a href="#Testing">Testing </a></li>
|
||||
<li><a href="#TODO">TODO </a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Topics</h2>
|
||||
<ul class="$(kind=='Topics' and '' or 'nowrap'">
|
||||
<li><strong>README</strong></li>
|
||||
</ul>
|
||||
<h2>Modules</h2>
|
||||
<ul class="$(kind=='Topics' and '' or 'nowrap'">
|
||||
<li><a href="../index.html">tiny-ecs</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
# tiny-ecs #
|
||||
Tiny-ecs is an Entity Component System for lua that's simple, flexible, and useful.
|
||||
Because of lua's tabular nature, Entity Component Systems are a natural choice
|
||||
for simulating large and complex systems. For more explanation on Entity
|
||||
Component Systems, here is some
|
||||
[basic info](http://en.wikipedia.org/wiki/Entity_component_system "Wikipedia").
|
||||
<p>## Use It ##
|
||||
Copy paste tiny.lua into your source folder.
|
||||
<p>## Overview ##
|
||||
Tiny-ecs has four important types: Worlds, Filters, Systems, and Entities.
|
||||
Entities, however, can be any lua table, and Filters are just functions that
|
||||
take an Entity as a parameter.
|
||||
<p>### Entities ###
|
||||
Entities are simply lua tables of data that gets processed by Systems. Entities
|
||||
should contain primarily data rather that code, as it is the Systems's job to
|
||||
do logic on data. Henceforth, a key-value pair in an Entity will
|
||||
be referred to as a Component.
|
||||
<p>### Worlds ###
|
||||
Worlds are the outermost containers in tiny-ecs that contain both Systems
|
||||
and Entities. In typical use, only one World is used at a time.
|
||||
<p>### Systems ###
|
||||
Systems in tiny-ecs describe how to update Entities. Systems select certain Entities
|
||||
using a Filter, and then only update those select Entities. Some Systems don't
|
||||
update Entities, and instead just act as function callbacks every update. Tiny-ecs
|
||||
provides functions for creating Systems easily.
|
||||
<p>### Filters ###
|
||||
Filters are used to select Entities. Filters can be any lua function, but
|
||||
tiny-ecs provides some functions for generating common ones, like selecting
|
||||
only Entities that have all required components.
|
||||
<p>## Example ##
|
||||
```lua
|
||||
local tiny = require("tiny")
|
||||
<p>local talkingSystem = tiny.processingSystem(
|
||||
tiny.requireAll("name", "mass", "phrase"),
|
||||
function (p, delta)
|
||||
p.mass = p.mass + delta * 3
|
||||
print(p.name .. ", who weighs " .. p.mass .. " pounds, says, \"" .. p.phrase .. "\"")
|
||||
end
|
||||
)
|
||||
<p>local joe = {
|
||||
name = "Joe",
|
||||
phrase = "I'm a plumber.",
|
||||
mass = 150,
|
||||
hairColor = "brown"
|
||||
}
|
||||
<p>local world = tiny.newWorld(talkingSystem, joe)
|
||||
<p>for i = 1, 20 do
|
||||
world:update(1)
|
||||
end
|
||||
```
|
||||
<p>## Testing ##
|
||||
Tiny-ecs uses [busted](http://olivinelabs.com/busted/) for testing. Install and run
|
||||
`busted` from the command line to test.
|
||||
<p>## TODO ##
|
||||
<p>* Dynamic reordering of Systems
|
||||
* More testing
|
||||
* Performance testing / optimization
|
||||
* API outside of source code
|
||||
* Add more complete examples
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
|
||||
<i style="float:right;">Last updated 2015-03-29 17:53:00 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user