Roblox-TS typings for Matter made by @evaera and @lpghatguy.
npm i @rbxts/matter
import { component, Loop, World } from "@rbxts/matter"
const world = new World()
const Balance = component<{ amount: number }>()
const Name = component<{ name: string} >()
const WantsMoney = component<{ flag: boolean }>()
const Marcus = world.spawn(Balance({ amount: 1000 }), Name({ name: "Marcus" }), WantsMoney({ flag: true }))
const Jade = world.spawn(Balance({ amount: 1000 }), Name({ name: "Jade" }), WantsMoney({ flag: false }))
for (const [entityId, bal, name, wantsMoney] of world.query(Balance, Name, WantsMoney)) {
if (wantsMoney.flag) world.insert(entityId, bal.patch({ amount: bal.amount + 500 }))
}
assert(world.get(Marcus, Amount).amount === 1500)
assert(world.get(Jade, Amount).amount === 1000)
To see Matter used in a game, see Ukendio/For-Animia
See Evaera/Matter
- Republished Matter (from GitHub commit d0df77f)