aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoop Kiefte <ikojba@gmail.com>2020-12-02 21:34:00 +0100
committerJoop Kiefte <ikojba@gmail.com>2020-12-02 21:34:00 +0100
commit3915b4307b7501828f69588cdf2068cd5da3e50e (patch)
tree1d0e3b84b00fbd761b72ea51b4900562007dd0e6
parent3be3e76ddafe4b8f0cb971a6bdd92625b67bc952 (diff)
Add restart option
-rw-r--r--main.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/main.go b/main.go
index a8db9ac..5bd752f 100644
--- a/main.go
+++ b/main.go
@@ -54,6 +54,7 @@ func GetKey(t *term.Term) []byte {
}
func main() {
+restart:
var startlevel int
if len(os.Args) > 1 {
startlevel, _ = strconv.Atoi(os.Args[1])
@@ -189,7 +190,18 @@ func main() {
if topout {
ppos(4, 15, " GAME OVER ")
- return
+ break
}
}
+ ppos(6, 15, " replay? [Y/n] ")
+ t.Restore() // return from raw mode
+ var yes string
+ fmt.Scanln(&yes)
+ if len(yes) < 1 {
+ goto restart
+ }
+ if yes[0] == 'n' || yes[0] == 'N' {
+ return
+ }
+ goto restart
}