-
Notifications
You must be signed in to change notification settings - Fork 0
/
render.go
58 lines (47 loc) · 1.29 KB
/
render.go
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
package main
import (
"fmt"
"strings"
"github.com/charmbracelet/lipgloss"
)
func RenderPlayground(m *Model) {
for i := 0; i < m.height; i++ {
m.battleground = append(m.battleground, strings.Split(strings.Repeat(" ", m.width), ""))
}
m.battleground = append(m.battleground, strings.Split(strings.Repeat(m.borderSymbol, m.width), ""))
}
func RenderInvader(m *Model) {
for i, val := range m.invaders {
m.battleground[i][val.position] = val.appearance
}
}
func RenderScore(score int) string {
scoreStr := fmt.Sprintf("Score: %d ", score)
ts := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("10"))
return ts.Render(scoreStr)
}
func RenderTitle() string {
ts := lipgloss.NewStyle().Bold(true).
Foreground(lipgloss.Color("229")).
Background(lipgloss.Color("63")).
Width(30).
AlignHorizontal(lipgloss.Center).
MarginTop(1).
MarginBottom(1).
Underline(true)
return ts.Render("ALPHABET INVASION")
}
func RenderQuitcommand() string {
qc := "Press ctrl+c to quit"
ts := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("63"))
return ts.Render((qc))
}
func RenderGameOver() string {
return lipgloss.NewStyle().Bold(true).
Foreground(lipgloss.Color("#FAFAFA")).
Width(30).
AlignHorizontal(lipgloss.Center).
MarginTop(1).
MarginBottom(1).
Render("Game Over!")
}