Hello Elm people!

I'm making a 2D video game to familiarize myself with Elm and I have a 
design issue I would like to hear your advice on.

In my game I have different UI entities with different behaviours, for 
example:

   - Some are collidable with the player / other entities, but other are 
   not.
   - Some move in the game world while other not (the view port might 
   change, but their game world position does not).
   - Some have AI logic that controls how they move, others are dumb.
   - Some interact with the mouse cursor while others do not.

I'm not sure how to model the different entities. In OOP scenario I would 
use a hierarchy of types and mixin types. In Aspect oriented programming I 
would compose them from different aspects. I'm not sure what I should do in 
Elm.

I have some constraints, for example, I need to hold all entities (accept, 
maybe, background entities without any interaction at all) in one data 
structure that will make collision detection easy, like a quadtree. They 
all need to be rendered when they are in the view port. I might need to 
implement some kind of path-finding algorithm.


I tried using this syntax:

type alias Positioned a =
  { a | x : Float, y : Float }

But I can't make a List or Tree of "Positioned a" and then pattern match on 
"a". Or at least, if I can I couldn't figure out a way to make it work.


Any suggestions would be appreciated!


-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to