Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Game dev in elixir with ECS

ecs.livemd

Game dev in elixir with ECS

What is Entity-Component-System (ECS)?

Entity

  • just an id

Component

  • just data
  • position, velocity, animation, texture, health, damage, attack, lighting_damage, …

System

  • logic
  • takes all entities with components x,y,z; updates data
  • MovementSystem
    • takes all entities with position and velocity
    • updates position based on velocity

What does that look like?

new_state =
  old_state
  |> Snake.Systems.Movement.run()
  |> Snake.Systems.Animation.run()
  |> Snake.Systems.Collision.run()
  |> Snake.Systems.FoodEating.run()
  |> Snake.Systems.FoodSpawning.run()

# and then just render the state

Demo time

Should we use live view?

  • For hobby or generally simple/casual games? Sure, why not?
  • Great for multiplayer
  • There’s input lag
  • Inefficient
  • Partially fixed by more JS

If not liveview, what?

:wx
:gl

Thank you!

https://github.com/begedin/livepixel

https://github.com/harrisi/elixir_breakout - Ian Harris