Skip to content

Commit 190fc1d

Browse files
committed
fix version string in help
1 parent 80a3b33 commit 190fc1d

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ demo: build
1717
./go-mines
1818

1919
dist:
20-
gox -ldflags="-s -w -X main.version=${VERSION}" \
20+
gox -ldflags="-s -w -X github.com/jedib0t/go-mines/game.version=${VERSION}" \
2121
-os="linux darwin windows" \
2222
-arch="amd64" \
2323
-output="./dist/{{.Dir}}_{{.OS}}_{{.Arch}}" \

game/game.go

+29-29
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var (
1313
// game state
1414
cursor = minefield.Position{X: 0, Y: 0}
1515
mf *minefield.Minefield
16-
userQuit bool
16+
userQuit = false
1717

1818
// demo
1919
demoRNG = rand.New(rand.NewSource(1))
@@ -27,6 +27,34 @@ var (
2727
numRows = 15
2828
)
2929

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+
3058
func demo() {
3159
moveAndDo := func(x, y int, f func(x, y int)) {
3260
moveCursorTo(x, y, demoSpeed/2)
@@ -99,31 +127,3 @@ func getUserInput() {
99127
}
100128
}
101129
}
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-
}

0 commit comments

Comments
 (0)