-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
61 lines (54 loc) · 1.31 KB
/
main.go
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
additions "github.com/Chownie/Termbox-Additions"
"github.com/Chownie/Termbox-Additions/utils"
"github.com/nsf/termbox-go"
"log"
"math/rand"
"os"
"time"
)
var (
Loggy *log.Logger
)
func main() {
err := termbox.Init()
if err != nil {
panic(err)
}
defer termbox.Close()
width, height := termbox.Size()
f, err := os.OpenFile("errLog.txt", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
panic("error opening/writing file")
}
defer f.Close()
Loggy = log.New(f, "", 0)
rng := rand.New(rand.NewSource(time.Now().UTC().UnixNano()))
gameState := new(GameState)
gameState.GameMap = BlankMap(80, 20)
gameState.ScreenWidth = width
gameState.ScreenHeight = height
gameState.RNG = rng
gameState.Messages = &[]string{"", "", ""}
gameState.Mode = MODE_SPLASH
for {
termbox.Clear(termbox.ColorWhite, termbox.ColorDefault)
gameState.GameLoop()
if gameState.Mode == MODE_SPLASH {
switch ev := termbox.PollEvent(); ev.Type {
case termbox.EventKey:
switch ev.Key {
case termbox.KeyEsc:
choice := additions.DrawMenu(width, height, "Are you sure you want to quit?", []string{"Yes", "No"}, additions.AL_CENTER, utils.CONNECT_NONE)
if choice == 0 {
termbox.Close()
os.Exit(0)
}
default:
gameState.Mode = MODE_MAPMAKE
}
}
}
}
}