forked from codelympics/go_game_jam
/
main.go
61 lines (50 loc) · 1.06 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 (
_ "fmt"
tb "github.com/nsf/termbox-go"
"os"
)
const helpMessage = "Honestly, there is no help yet. You're pretty much going to have to figure it out - I'm making this game up as I go along and the plan is to get somewhere within a weekend so who knows how well that will go. Probably not well at all, but maybe that's okay. it's turn based, dust is a good and a bad thing, and I only have a vague idea where I'm going with this."
func loop(s state) {
for {
render(s)
switch ev := tb.PollEvent(); ev.Type {
case tb.EventKey:
switch ev.Key {
case tb.KeyEsc:
os.Exit(0)
break
case tb.KeySpace:
s = turn(s)
break
default:
switch ev.Ch {
case keyq:
os.Exit(0)
break
case keyh:
s.message = helpMessage
render(s)
break
default:
s.nextTurnEvent = ev
break
}
}
}
}
}
func main() {
err := tb.Init()
if err != nil {
panic(err)
}
defer tb.Close()
s := state{
firsts: map[string]bool{
collector.name: true,
searcher.name: true,
},
}
loop(s)
}