blob: b58612976591df1cca1e8bb4fff7edbd56d485b0 (
plain)
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
77
78
79
80
81
82
83
84
85
86
87
88
|
module Display where
import Vec2 (..)
import Player (..)
import Game (Game)
import Enemy (..)
import Board (boardSize)
import Target (..)
display : Game -> Element
display {time, player, target, enemyState, bestScore} =
let enemyForms = map (enemyForm time) enemyState.enemies
forms = boardForms
++ playerForms player
++ targetForms target.pos
++ enemyForms
++ scoreForms target.score
++ bestScoreForms bestScore
in collage (truncate boardSize.x) (truncate boardSize.y) forms
boardForms : [Form]
boardForms = [filled boardColor (rect boardSize.x boardSize.y)]
boardColor : Color
boardColor = rgb 17 17 17
playerForms : Player -> [Form]
playerForms player = [circleForm player.pos playerSize playerColor]
playerColor : Color
playerColor = rgb 224 224 224
targetForms : Vec2 -> [Form]
targetForms pos = [circleForm pos targetSize targetColor]
targetColor : Color
targetColor = rgb 34 85 34
enemyForm : Float -> Enemy -> Form
enemyForm time enemy =
let pos = enemyMove enemy time
in circleForm pos enemySize enemyColor
enemyColor : Color
enemyColor = rgb 170 0 0
circleForm : Vec2 -> Float -> Color -> Form
circleForm pos size color =
let outline = circle size
|> filled outlineColor
inside = circle (size - 1)
|> filled color
in group [outline, inside]
|> move (pos.x, pos.y)
outlineColor : Color
outlineColor = rgb 34 34 34
scoreForms : Int -> [Form]
scoreForms score =
let text = (show score)
scorePos = { x = 0.0, y = boardSize.y / 2 - 30 }
in [textForm text scorePos centered]
bestScoreForms : Int -> [Form]
bestScoreForms bestScore =
if(bestScore > 0) then
let text = "Record: " ++ (show bestScore)
pos =
{ x = boardSize.x / 2 - 65
, y = -boardSize.y / 2 + 30
}
in [textForm text pos rightAligned]
else []
textForm : String -> Vec2 -> (Text -> Element) -> Form
textForm content pos alignment =
let textElement = toText content
|> typeface ["calibri", "arial"]
|> Text.color textColor
|> bold
|> alignment
in textElement
|> toForm
|> move (pos.x, pos.y)
textColor : Color
textColor = rgb 224 224 224
|