File tree 2 files changed +30
-30
lines changed
2 files changed +30
-30
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ demo: build
17
17
./go-mines
18
18
19
19
dist :
20
- gox -ldflags=" -s -w -X main .version=${VERSION} " \
20
+ gox -ldflags=" -s -w -X github.com/jedib0t/go-mines/game .version=${VERSION} " \
21
21
-os=" linux darwin windows" \
22
22
-arch=" amd64" \
23
23
-output=" ./dist/{{.Dir}}_{{.OS}}_{{.Arch}}" \
Original file line number Diff line number Diff line change 13
13
// game state
14
14
cursor = minefield.Position {X : 0 , Y : 0 }
15
15
mf * minefield.Minefield
16
- userQuit bool
16
+ userQuit = false
17
17
18
18
// demo
19
19
demoRNG = rand .New (rand .NewSource (1 ))
27
27
numRows = 15
28
28
)
29
29
30
+ // Play starts the game.
31
+ func Play () {
32
+ defer cleanup ()
33
+ generateMineField ()
34
+
35
+ // render forever in a separate routine
36
+ chStop := make (chan bool , 1 )
37
+ wg := sync.WaitGroup {}
38
+ wg .Add (1 )
39
+ go renderAsync (chStop , & wg )
40
+
41
+ for {
42
+ if mf .IsGameOver () || userQuit {
43
+ break
44
+ }
45
+
46
+ if * flagDemo {
47
+ demo ()
48
+ } else {
49
+ getUserInput ()
50
+ }
51
+ }
52
+
53
+ renderGame () // one final render
54
+ chStop <- true
55
+ wg .Wait ()
56
+ }
57
+
30
58
func demo () {
31
59
moveAndDo := func (x , y int , f func (x , y int )) {
32
60
moveCursorTo (x , y , demoSpeed / 2 )
@@ -99,31 +127,3 @@ func getUserInput() {
99
127
}
100
128
}
101
129
}
102
-
103
- // Play starts the game.
104
- func Play () {
105
- defer cleanup ()
106
- generateMineField ()
107
-
108
- // render forever in a separate routine
109
- chStop := make (chan bool , 1 )
110
- wg := sync.WaitGroup {}
111
- wg .Add (1 )
112
- go renderAsync (chStop , & wg )
113
-
114
- for {
115
- if mf .IsGameOver () || userQuit {
116
- break
117
- }
118
-
119
- if * flagDemo {
120
- demo ()
121
- } else {
122
- getUserInput ()
123
- }
124
- }
125
-
126
- renderGame () // one final render
127
- chStop <- true
128
- wg .Wait ()
129
- }
You can’t perform that action at this time.
0 commit comments