Orasund/elm-card-game/1.0.0

Game.Entity

module for working with entities.

Entity

type alias Entity a =
{ position : ( Float, Float )
, rotation : Float
, customTransformations : List Transformation
, zIndex : Int
, content : a
}

A entity allows for different relative transformations like rotating or moving by a relative amount.

new : a -> Entity a

construct a entity

toAttributes : Entity a -> ( a, List (Attribute msg) )

Attributes of a Entity

List (Attribute msg)
-> Entity (List (Attribute msg) -> Html msg)
-> Html msg

turn the entity into html

Html msg
-> List (Entity (List (Attribute msg) -> Html msg))
-> Entity (List (Attribute msg) -> Html msg)

Group Entities into a pile

move : ( Float, Float ) -> Entity a -> Entity a

move a entity

rotate : Float -> Entity a -> Entity a

rotate a entity

map : (a -> b) -> Entity a -> Entity b

map the content of a entity

mapCustomTransformations : (List Transformation -> List Transformation) -> Entity a -> Entity a

map custom transformations

mapPosition : (( Float, Float ) -> ( Float, Float )) -> Entity a -> Entity a

map position

mapRotation : (Float -> Float) -> Entity a -> Entity a

map rotation

mapZIndex : (Int -> Int) -> Entity a -> Entity a

map z-index

List (Attribute msg)
-> { front : Entity (List (Attribute msg) -> Html msg)
, back : Entity (List (Attribute msg) -> Html msg)
, faceUp : Bool
}
-> Entity (List (Attribute msg) -> Html msg)

Create an entity that can be flipped

For technical reasons we needed to provide a width. Default is a ratio of 2/3

You can overrule the default by providing a width:

height = 200


ratio = 2/3


flippable [Html.Attributes.style "width" (String.fromFloat (height * ratio) ++ "px")]
perspective : Attribute msg

Activates a 3d-effect for the child notes. Should be used in combination with flip

Transformation

type alias Transformation =
String

A transformation string

transform : List Transformation -> Attribute msg

Add transformations to a card

scale : Float -> Transformation

Scale the card

moveTransformation : ( Float, Float ) -> Transformation

Move the card

rotateTransformation : Float -> Transformation

Rotate the card by a radial.

flipTransformation : Float -> Transformation

Flip the card. Only works if the outer div has a perspective Attribute