Create main menu for the game

This commit is contained in:
raul 2024-03-12 12:16:33 +01:00
parent 55b99e0b2c
commit 6f23e5d7a6
1 changed files with 53 additions and 2 deletions

55
main.go
View File

@ -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:
}
}
}