forked from deadprogram/flappy-gopher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwall.go
45 lines (35 loc) · 906 Bytes
/
wall.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
package main
import "github.com/firefly-zero/firefly-go/firefly"
const (
wallWidth = 8 // 壁の幅
wallHeight = 128 // 壁の高さ
holeYMax = 48 // 穴のY座標の最大値
holeHeight = 40 // 穴のサイズ(高さ)
)
type wallData struct {
wallX int
holeY int
}
func (w *wallData) move() {
w.wallX -= 8
}
func (w *wallData) draw() {
// 上の壁の描画
firefly.DrawImage(wallImage, firefly.Point{X: w.wallX, Y: w.holeY - wallHeight})
// 下の壁の描画
firefly.DrawImage(wallImage, firefly.Point{X: w.wallX, Y: w.holeY + holeHeight})
}
func (w *wallData) top() (int, int, int, int) {
l := w.wallX
t := w.holeY - wallHeight
r := w.wallX + wallWidth
b := w.holeY
return l, t, r, b
}
func (w *wallData) bottom() (int, int, int, int) {
l := w.wallX
t := w.holeY + holeHeight
r := w.wallX + wallWidth
b := w.holeY + holeHeight + wallHeight
return l, t, r, b
}