mirror of
https://github.com/bakpakin/tiny-ecs.git
synced 2026-07-22 07:56:52 -06:00
Change Example
This commit is contained in:
@@ -47,10 +47,9 @@ local System = jojo.System
|
|||||||
|
|
||||||
local personAspect = Aspect({"name", "mass", "phrase"})
|
local personAspect = Aspect({"name", "mass", "phrase"})
|
||||||
local talkingSystem = System(
|
local talkingSystem = System(
|
||||||
function (delta)
|
nil,
|
||||||
print("Talking system has started.")
|
|
||||||
end,
|
|
||||||
function (p, delta)
|
function (p, delta)
|
||||||
|
p.mass = p.mass + delta * 3
|
||||||
print(p.name .. ", who weighs " .. p.mass .. " pounds, says, \"" .. p.phrase .. "\"")
|
print(p.name .. ", who weighs " .. p.mass .. " pounds, says, \"" .. p.phrase .. "\"")
|
||||||
end,
|
end,
|
||||||
personAspect
|
personAspect
|
||||||
@@ -61,13 +60,15 @@ local world = World(talkingSystem)
|
|||||||
local joe = {
|
local joe = {
|
||||||
name = "Joe",
|
name = "Joe",
|
||||||
phrase = "I'm a plumber.",
|
phrase = "I'm a plumber.",
|
||||||
mass = 250,
|
mass = 150,
|
||||||
hairColor = "brown"
|
hairColor = "brown"
|
||||||
}
|
}
|
||||||
|
|
||||||
world:add(joe)
|
world:add(joe)
|
||||||
|
|
||||||
world:update(1)
|
for i = 1, 20 do
|
||||||
|
world:update(1)
|
||||||
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
## Testing ##
|
## Testing ##
|
||||||
|
|||||||
Reference in New Issue
Block a user