-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
39 lines (31 loc) · 698 Bytes
/
Copy pathmain.go
File metadata and controls
39 lines (31 loc) · 698 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"log"
"sync"
"github.com/gdamore/tcell"
)
func main() {
config, err := LoadConfig("config.json")
if err != nil {
log.Println("Could not load config, using defaults:", err)
config = NewConfig()
}
screen, err := tcell.NewScreen()
if err != nil {
panic(err)
}
if err := screen.Init(); err != nil {
panic(err)
}
defer screen.Fini()
var wg sync.WaitGroup
wg.Add(2)
// Create a new random number generator with a seed based on the current time
game := NewGameWithScreen(screen, config)
go game.Run(&wg)
go game.ListenForInput(&wg)
wg.Wait()
if err := config.SaveConfig("config.json"); err != nil {
log.Println("Error saving config:", err)
}
}