/
Tileset.elm
76 lines (64 loc) · 1.84 KB
/
Tileset.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
module TilesetExample exposing (main)
import Css
import Html.Styled exposing (toUnstyled)
import PixelEngine.Graphics as Graphics exposing (Background)
import PixelEngine.Graphics.Image exposing (image, multipleImages)
import PixelEngine.Graphics.Tile as Tile
exposing
( Tileset
, tile
)
main =
let
tileSize : Int
tileSize =
16
windowWidth : Int
windowWidth =
16
scale : Float
scale =
2
width : Float
width =
(toFloat <| windowWidth * tileSize) * scale
tileset : Tileset
tileset =
{ source = "tileset.png", spriteWidth = tileSize, spriteHeight = tileSize }
background : Background
background =
Graphics.colorBackground (Css.rgb 20 12 28)
--Image { src = "background.png", width = 16 * scale, height = 16 * scale }
goblin =
tile ( 2, 8 ) |> Tile.animated 1
letter_h =
tile ( 1, 15 )
letter_i =
tile ( 2, 12 )
heart =
tile ( 4, 8 )
in
Graphics.render
{ width = width, transitionSpeedInSec = 0.2, scale = scale }
[ Graphics.tiledArea
{ rows = 4
, tileset = tileset
, background = background
}
[ ( ( 6, 2 ), goblin )
, ( ( 7, 2 ), letter_h )
, ( ( 8, 2 ), letter_i )
, ( ( 9, 2 ), heart )
]
, Graphics.imageArea
{ height = scale * (toFloat <| tileSize * 12)
, background = background
}
[ ( ( 0, 0 )
, multipleImages
[ ( ( width / 2 - 80 * scale, 0 ), image "pixelengine-logo.png" )
]
)
]
]
|> toUnstyled