-
Notifications
You must be signed in to change notification settings - Fork 1
/
tiles.elm
48 lines (31 loc) · 911 Bytes
/
tiles.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
module Tiles exposing (..)
import Html exposing (Html, div, img)
import Html.Attributes exposing (src, style)
-- Path Sprite
tileFromSpriteSheet : ( Int, Int ) -> Html msg
tileFromSpriteSheet =
imgFromSpriteSheet "terrain.png"
grass =
tileFromSpriteSheet ( 0, 0 )
vertPath =
tileFromSpriteSheet ( 32, 0 )
crossPath =
tileFromSpriteSheet ( 64, 0 )
horzPath =
tileFromSpriteSheet ( 0, 32 )
tPath =
tileFromSpriteSheet ( 32, 32 )
imgFromSpriteSheet : String -> ( Int, Int ) -> Html msg
imgFromSpriteSheet spriteSheet ( x, y ) =
img
[ src "empty.png"
, style
[ ( "width", "32px" )
, ( "height", "32px" )
, ( "background-image", "url(" ++ spriteSheet ++ ")" )
, ( "background-position"
, "-" ++ (toString x) ++ "px -" ++ (toString y) ++ "px"
)
]
]
[]