-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelp.go
131 lines (110 loc) · 3.72 KB
/
help.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package main
import (
"image/color"
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/text"
)
var helpSplash *ebiten.Image
var helpImageW = 100
var helpImageH = 60
func generateHelpSplashScreen() *ebiten.Image {
var topics [6]string
var images [6]*ebiten.Image
topics = [6]string{
"use arrow keys to pulse\nan electromagnet.",
"magnetic pieces will slide\none cell in that direction.",
"moving pieces push other\nmovable pieces.",
"push colored circles into\nmatching slots to win.",
"you can push hollow\nblocks.",
"black squares don't move.",
}
images = [6]*ebiten.Image{
generateHelpImageOne(),
generateHelpImageTwo(),
generateHelpImageThree(),
generateHelpImageFour(),
generateHelpImageFive(),
generateHelpImageSix(),
}
splash := ebiten.NewImage(w, h)
splash.Fill(bg)
opts := &ebiten.DrawImageOptions{}
opts.GeoM.Translate(0, float64(text.BoundString(*regular, "X").Dy()/2+10))
for i, topic := range topics {
splash.DrawImage(images[i], opts)
opts.GeoM.Translate(0, float64(h/(len(topics))))
text.Draw(splash, topic, *regular, 100, h*i/(len(topics))+text.BoundString(*regular, "X").Dy()+10, fg)
}
message := "'esc': continue"
text.Draw(splash, message, *regular, w/2-text.BoundString(*regular, message).Dx()/2, h-10, fg)
return splash
}
func generateHelpImageOne() *ebiten.Image {
arrowDimensions := text.BoundString(*regular, "X").Dy()
img := ebiten.NewImage(helpImageW, helpImageH)
img.Fill(bg)
opts := &ebiten.DrawImageOptions{}
opts.GeoM.Translate(float64(helpImageW/2-arrowDimensions/2), 0)
img.DrawImage(generateUpArrow(), opts)
opts.GeoM.Reset()
opts.GeoM.Translate(float64(helpImageW/2-arrowDimensions*2), float64(helpImageH/2-arrowDimensions/2))
img.DrawImage(generateLeftArrow(), opts)
opts.GeoM.Reset()
opts.GeoM.Translate(float64(helpImageW/2+arrowDimensions), float64(helpImageH/2-arrowDimensions/2))
img.DrawImage(generateRightArrow(), opts)
opts.GeoM.Reset()
opts.GeoM.Translate(float64(helpImageW/2-arrowDimensions/2), float64(helpImageH-arrowDimensions))
img.DrawImage(generateDownArrow(), opts)
return img
}
func generateHelpImageTwo() *ebiten.Image {
img := ebiten.NewImage(helpImageW, helpImageH)
img.Fill(bg)
opts := &ebiten.DrawImageOptions{}
img.DrawImage(generateMagnetImage(), nil)
opts.GeoM.Translate(30, 7)
img.DrawImage(generateRightArrow(), opts)
return img
}
func generateHelpImageThree() *ebiten.Image {
img := ebiten.NewImage(helpImageW, helpImageH)
img.Fill(bg)
img.DrawImage(generateMagnetImage(), nil)
opts := &ebiten.DrawImageOptions{}
opts.GeoM.Translate(30, 0)
img.DrawImage(generateGemImage(color.RGBA{R: 255, G: 0, B: 0, A: 255}), opts)
opts.GeoM.Translate(30, 7)
img.DrawImage(generateRightArrow(), opts)
return img
}
func generateHelpImageFour() *ebiten.Image {
img := ebiten.NewImage(helpImageW, helpImageH)
img.Fill(bg)
img.DrawImage(generateGemImage(color.RGBA{R: 255, G: 0, B: 0, A: 255}), nil)
opts := &ebiten.DrawImageOptions{}
opts.GeoM.Translate(50, 0)
img.DrawImage(generateTargetImage(color.RGBA{R: 255, G: 0, B: 0, A: 255}), opts)
opts.GeoM.Translate(-20, 7)
img.DrawImage(generateRightArrow(), opts)
return img
}
func generateHelpImageFive() *ebiten.Image {
img := ebiten.NewImage(helpImageW, helpImageH)
img.Fill(bg)
img.DrawImage(generateMagnetImage(), nil)
opts := &ebiten.DrawImageOptions{}
opts.GeoM.Translate(30, 0)
img.DrawImage(generateBlockImage(), opts)
opts.GeoM.Translate(30, 7)
img.DrawImage(generateRightArrow(), opts)
return img
}
func generateHelpImageSix() *ebiten.Image {
img := ebiten.NewImage(helpImageW, helpImageH)
img.Fill(bg)
img.DrawImage(generateMagnetImage(), nil)
opts := &ebiten.DrawImageOptions{}
opts.GeoM.Translate(30, 0)
img.DrawImage(generatePostImage(), opts)
return img
}