-
Notifications
You must be signed in to change notification settings - Fork 2
/
title.go
113 lines (93 loc) · 2.03 KB
/
title.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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package main
import sprite "github.com/pdevine/go-asciisprite"
type Title struct {
sprite.BaseSprite
state uint
VX int
VY int
TargetY int
}
const (
dropin = iota
resting
)
const logo = `[][][] [][] [][][] [][] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [][][][] [] [][] [] [] []
[] [][] [] [][] [] [] [] [] [] [] [] [][] [] []
[] [] [] [] [] [] [] [] [] [] [] [] [] []
[] [][] [] [] [] [] [] [] [] [] [] []
`
const elek_costume1 = "e l e k t r o n i k a"
const elek_costume2 = "Электроника"
const copyright1 = "(c) 2019 Patrick Devine\n patrick@immense.ly"
const instructions1 = "Press any key to continue"
func NewTitle() *Title {
s := &Title{BaseSprite: sprite.BaseSprite{
X: 17,
Y: -10,
Visible: true,
},
VY: 2,
TargetY: 5,
state: dropin,
}
s.AddCostume(sprite.NewCostume(logo, '%'))
return s
}
func (s *Title) Update() {
switch {
case s.state == dropin:
if s.Y < s.TargetY {
s.Y += s.VY
} else {
if s.state != resting {
s.state = resting
for _, spr := range []*sprite.BaseSprite{NewCopyright(), NewInstructions()} {
allSprites.Sprites = append(allSprites.Sprites, spr)
}
}
}
}
}
type TitleString struct {
sprite.BaseSprite
Timer int
TimeOut int
}
func NewTitleString() *TitleString {
s := &TitleString{BaseSprite: sprite.BaseSprite{
X: 38,
Y: 12,
Visible: true,
},
TimeOut: 100,
}
s.AddCostume(sprite.NewCostume(elek_costume1, '!'))
s.AddCostume(sprite.NewCostume(elek_costume2, '!'))
return s
}
func (s *TitleString) Update() {
s.Timer++
if s.Timer >= s.TimeOut {
s.NextCostume()
s.Timer = 0
}
}
func NewCopyright() *sprite.BaseSprite {
s := &sprite.BaseSprite{
X: 37,
Y: 14,
Visible: true,
}
s.AddCostume(sprite.NewCostume(copyright1, '!'))
return s
}
func NewInstructions() *sprite.BaseSprite {
s := &sprite.BaseSprite{
X: 36,
Y: 23,
Visible: true,
}
s.AddCostume(sprite.NewCostume(instructions1, '!'))
return s
}