mirror of
https://github.com/Keyslam-Group/Concord.git
synced 2025-09-10 16:17:48 -04:00
Compare commits
No commits in common. "main" and "v4.0" have entirely different histories.
1 changed files with 9 additions and 14 deletions
23
README.md
23
README.md
|
@ -133,21 +133,16 @@ Concord does a few things that might not be immediately clear. This segment shou
|
||||||
Since you'll have lots of Components and Systems in your game Concord makes it a bit easier to load things in.
|
Since you'll have lots of Components and Systems in your game Concord makes it a bit easier to load things in.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- Loads all files in the directory. Components automatically register into Concord.components, so loading them into a namespace isn't necessary.
|
|
||||||
Concord.utils.loadNamespace("path/to/components")
|
|
||||||
|
|
||||||
print(Concord.components.componentName)
|
|
||||||
|
|
||||||
-- Loads all files in the directory, and puts the return value in the table Systems. The key is their filename without any extension
|
-- Loads all files in the directory, and puts the return value in the table Systems. The key is their filename without any extension
|
||||||
local Systems = {}
|
local Systems = {}
|
||||||
Concord.utils.loadNamespace("path/to/systems", Systems)
|
Concord.utils.loadNamespace("path/to/systems", Systems)
|
||||||
|
|
||||||
myWorld:addSystems(
|
print(Systems.systemName)
|
||||||
Systems.healthSystem
|
|
||||||
Systems.damageSystem,
|
-- Loads all files in the directory. Components automatically register into Concord.components, so loading them into a namespace isn't necessary.
|
||||||
Systems.moveSystem,
|
Concord.utils.loadNamespace("path/to/components")
|
||||||
-- etc
|
|
||||||
)
|
print(Concord.components.componentName)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Method chaining
|
#### Method chaining
|
||||||
|
@ -175,7 +170,7 @@ When defining a ComponentClass you need to pass in a name and usually a `populat
|
||||||
-- Create the position class with a populate function
|
-- Create the position class with a populate function
|
||||||
-- The component variable is the actual Component given to an Entity
|
-- The component variable is the actual Component given to an Entity
|
||||||
-- The x and y variables are values we pass in when we create the Component
|
-- The x and y variables are values we pass in when we create the Component
|
||||||
Concord.component("position", function(component, x, y)
|
Concord.component("position" function(component, x, y)
|
||||||
component.x = x or 0
|
component.x = x or 0
|
||||||
component.y = y or 0
|
component.y = y or 0
|
||||||
end)
|
end)
|
||||||
|
@ -299,14 +294,14 @@ end
|
||||||
-- Defining a function
|
-- Defining a function
|
||||||
function mySystemClass:update(dt)
|
function mySystemClass:update(dt)
|
||||||
-- Iterate over all entities in the Pool
|
-- Iterate over all entities in the Pool
|
||||||
for _, e in ipairs(self.pool) do
|
for _, e in ipairs(self.pool)
|
||||||
-- Do something with the Components
|
-- Do something with the Components
|
||||||
e.position.x = e.position.x + e.velocity.x * dt
|
e.position.x = e.position.x + e.velocity.x * dt
|
||||||
e.position.y = e.position.y + e.velocity.y * dt
|
e.position.y = e.position.y + e.velocity.y * dt
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Iterate over all entities in the second Pool
|
-- Iterate over all entities in the second Pool
|
||||||
for _, e in ipairs(self.secondPool) do
|
for _, e in ipairs(self.secondPool)
|
||||||
-- Do something
|
-- Do something
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue