System: main logic driver, that is used to stepping on each game-loop and update World
Update whole Component.Set
Single component mapping, Same asList.map - only for Component.Set inside World
gravitySystem =
Logic.System.step (Vec2.add gravity) accelerationSpecStep over all entities that have both components.
Example:
system =
Logic.System.step2
(\( v, _ ) ( p, setP ) -> setP (Vec2.add v p))
velocitySpec
positionSpecSame as step2 only with 3 components
Same as step2 only with 4 components
Same as step2 only with 5 components
Reduce a Component.Set from the left.
Example count how much enemies left in the world:
enemySet =
enemySpec.get world
count =
foldl (\_ -> (+) 1) enemySet 0Step over all entities that have both components and reduce an Component.Sets from the left.
Same as foldl2 only with 3 components
Same as foldl2 only with 4 components
Same as foldl2 only with 5 components
Variant of foldl that passes the index of the current element to the step function.
indexedFoldl is to foldl as List.indexedMap is to List.map.
Same as indexedFoldl2 only with 3 components
Same as indexedFoldl2 only with 4 components
Same as indexedFoldl2 only with 5 components
Just nice helper function to pipe into systems
update msg world =
world
|> system1
|> applyIf (msg === KeyUp "a") systemMoveLeft
|> system2Same as applyIf, but works with Maybe
update msg world =
world
|> system1
|> applyMaybe (decode saveDecoder msg) loadGame
|> system2