diff options
author | Joop Kiefte <ikojba@gmail.com> | 2020-12-02 21:34:00 +0100 |
---|---|---|
committer | Joop Kiefte <ikojba@gmail.com> | 2020-12-02 21:34:00 +0100 |
commit | 3915b4307b7501828f69588cdf2068cd5da3e50e (patch) | |
tree | 1d0e3b84b00fbd761b72ea51b4900562007dd0e6 | |
parent | 3be3e76ddafe4b8f0cb971a6bdd92625b67bc952 (diff) |
Add restart option
-rw-r--r-- | main.go | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -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 } |