iacobson

iacobson

ECSpanse - an Entity Component System framework for Elixir

ECSpanse

logo_small

Ecspanse is an Entity Component System (ECS) framework for Elixir.

Ecspanse is not a game engine, but a flexible foundation for managing state and building logic, with features like:

  • flexible queries with multiple filters
  • dynamic bidirectional relationships
  • versatile tagging capabilities
  • component templates
  • system event subscriptions
  • asynchronous system execution

Docs: Ecspanse — ECSpanse v0.10.1
GitHub: GitHub - iacobson/ecspanse: Entity Component System (ECS) library for Elixir, offering a suite of features including: flexible queries with multiple filters, dynamic bidirectional relationships, versatile tagging capabilities, system event subscriptions, or asynchronous system execution.
Article: https://iacobson.medium.com/elixir-for-fun-ecspanse-2852a7993ecd
Podcast: ECS / Game Development with Elixir vs. Python, JavaScript, React with Dorian Iacobescu & Daniel Luu | SmartLogic

Most Liked

stwf

stwf

OK. Finally got something I’m ready to show.

My game is an attempt at a Kriegsspiel. A 19th century wargame that emphasized realistic issues that came up in battle. Mine at least will try to take into account proper size scales, lines of supply and communication, how long orders take to arrive, and be executed, etc

I’ve got the hex map editor working and have basic movement and some commands working. Next up will be line of sight for identifying enemy units, and Scouts bringing back delayed observations of enemy units. That sort of thing. Then battle!

So it’s been fun and a good learning experience if nothing else! I’ll be happy to open up the code if there someone other than me interested in this sort of thing…


Steve

iacobson

iacobson

For whoever is interested, I’m invited to this Elixir Wizards podcast episode discussing ECS and Ecspanse: ECS / Game Development with Elixir vs. Python, JavaScript, React with Dorian Iacobescu & Daniel Luu | SmartLogic

iacobson

iacobson

Thanks. I think Ecspanse and ECSx try to solve the same “problem” but in different ways. I even mentioned ECSx as an alternative to Ecspanse in my Medium article.

Still, to try to answer your question, I think ECSx is more straightforward to get started with. You have generators and every component holds a single value. You can then query the individual components by their entity ID or as a list. But I think their guides section explains it better than I could.

On the other hand, Ecspanse has a bit more complicated approach, but I would say also offers more flexibility as the game becomes more complex. I would mention just a few of them:

You can find some more details and examples in the Medium article.

stwf

stwf

Thanks!
So yes. The map editor part stores the maps in Postgres. But I export them to JSON files to load in the game. They are loaded into Ecspanse and stored globally so multiple games can use them and not require separate copies.

And yes the map is BablylonJS and LiveView for the rest. I’m trying to keep the BabylonJs stuff as simple as possible for the game. It just renders the maps, knows how to draw units, and reports on what items get clicked on.

LiveView handles the UI state, and sends orders into Ecspanse, and when I get notifications from the Projections I just push the unit data into BabylonJS through a LiveView hook.

I will keep you in the loop for sure. Just couple of more features and I will work on getting it deployed… same old story lol. Thanks for the library and support!

iacobson

iacobson

New release v0.10.0

Introduces the introduces Ecspanse.Snapshot module to enable custom save and load solutions.

Check the new guide for some implementation ideas. And of course, let me know what you think

Where Next?

Popular in Libraries Top

mhanberg
I just released the first version of Temple: an HTML DSL for Elixir and Phoenix! You can read this blog post or the docs for more info...
New
tmbb
I’ve been working on two packages (not on hex.pm yet) to build admin interfaces for phoenix apps: bureaucrat - which contains a bunch ...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. Features Unstyled Phoenix components. Storybook that can be added to...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
OvermindDL1
Been making an MLElixir thing (not released yet…) for fun in spare time in the past day. I’m just trying to see how much I can get an ML...
132 13487 106
New
danschultzer
In short Plug n’ play OAuth 2.0 provider library. Just set up a resource owner schema with Ecto (your user schema), install the dependen...
New
benlime
LiveMotion enables high performance animations declared on the server and run on the client. As a follow up to my previous thread A libr...
New
Crowdhailer
Experimenting with this code. OK.try do user <- fetch_user(1) cart <- fetch_cart(1) order = checkout(cart, user) save_or...
New
OvermindDL1
I created a new library (rather I pulled out a couple files from my big project), it manages an operating system PID file for the BEAM. ...
New
bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
381 12391 119
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New

Sub Categories:

We're in Beta

About us Mission Statement