From 6f23e5d7a6a43648ece2051800a01014144739b0 Mon Sep 17 00:00:00 2001 From: raul Date: Tue, 12 Mar 2024 12:16:33 +0100 Subject: [PATCH] Create main menu for the game --- main.go | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index aab7c20..172575d 100644 --- a/main.go +++ b/main.go @@ -2,8 +2,59 @@ package main import ( "fmt" + "os" + "strconv" ) -func main() { - fmt.Println("Sample text") +func asciiLogo() { + fmt.Println(` + # # ( ) + ___#_#___|__ + _ |____________| _ + _=====| | | | | |==== _ + =====| |.---------------------------. | |==== + <--------------------' . . . . . . . . '--------------/ + \ / + \___________________________________________________________/ + `) +} + +func startMenu() { + fmt.Println("[1] Singleplayer") + fmt.Println("[2] Join server") + fmt.Println("[3] Host server") + fmt.Println("[4] Quit") + fmt.Printf("\nChoice: ") +} + +func quitPrompt() { + fmt.Printf("Do you wish to quit? [y/n] ") + choice := scanLine() + if choice == "y" { + os.Exit(0) + } +} + +func main() { + for { + clear() + asciiLogo() + startMenu() + strchoice := scanLine() + choice, _ := strconv.Atoi(strchoice) + switch choice { + case 1: + singleplayer() + break + case 2: + client() + case 3: + server() + case 4: + quitPrompt() + default: + + } + + } }