Entity-Component system for Elm game development

I’ve been working on a Super Mario clone in Elm.
I’ve been building it gradually, starting with just Mario, then a level made up of Tiles. Then I’ve introduced collision detection with the tiles. Then I’ve introduced the first enemy, a Goomba and to do so I’ve abstracted away the concept of an entity and I’ve generalised most of the physics code.
Now I’m reaching the point where I’d like to animating tiles, colliding tiles and entities, and entities with other entities.
A tile when animated, and an entity like Mario are not too dissimilar from each other. In other languages at this point I would follow ECS: https://www.wikiwand.com/en/Entity–component–system

I’ve found someone on the internet exploring an ECS in Elm: https://gist.github.com/TheSeamau5/4fc43cb00253f4e5d7b4

What are approaches are you using to structure games in Elm, maybe more specifically 2d platformers?

Thanks.

2 Likes

Coool! What a coincidence. I have been building a Boulder Dash kinda game in Elm with the Actor/Component system since last week!

Here is the WIP code: https://github.com/JordyMoos/elm-pixel-boulder-game
And a demo: https://jordymoos.github.io/elm-pixel-boulder-game/

Do you have your code on github?

Hello there, thanks for the links.
My mario clone attempt is at: https://github.com/soulnafein/mario
Keep in mind that I’m teaching myself Elm at the moment and I’m still exploring the ideal architecture for this so the code isn’t great.

npm install && npm start it.
Demo here: https://soulnafein.github.io/mario/
Z to jump, arrow keys to move

1 Like

Thanks Soulnafein

It is always useful to check and learn from each others code. Thanks for sharing!
As of the main question. The game I’m working on and trying to apply the component system is all in the src/elm/Actor.elm file. But I do not have real Physics stuff etc, not sure if it is really useful for you. What it does have is strong separation of concerns with the components.

Got luck with your project!

There is this one: http://package.elm-lang.org/packages/seurimas/slime/latest

1 Like

Andre gave a great talk at last year’s elm-conf about game development, where he discussed using an ECS in Elm.

Here’s the talk: https://youtu.be/NRXTMaXO15I
Here’s the repo for his game: https://github.com/w0rm/elm-mogee

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.