-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
110 lines (97 loc) · 3.41 KB
/
config.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package main
import (
"time"
"github.com/benrhyshoward/termtron/model"
"github.com/nsf/termbox-go"
)
//GameStepLength : shorter step -> faster game
var GameStepLength = time.Duration(50) * time.Millisecond
//AverageAIDirectionChangePeriod :
//Decrease/increase value to make AI direction changes more/less frequent
//More frequent changes tend to make the AI perform worse
//Values < 1 will cause a panic
var AverageAIDirectionChangePeriod = 20
//CountdownLength : number of seconds to countdown before the start of each game
var CountdownLength = 3
//TerminalWidth : updated in game loop
var TerminalWidth int
//TerminalHeight : updated in game loop
var TerminalHeight int
//Scaling factors used to account for terminal cells not being square
//They define how many horizontal and vertical cells should make up a single point in the game
//XScalingFactor = 2 and YScalingFactor = 1 tends to give best results
var XScalingFactor = 2
var YScalingFactor = 1
//ScaledTerminalWidth : TerminalWidth with X scaling factor applied, updated in game loop
var ScaledTerminalWidth int
//ScaledTerminalHeight : TerminalHeight with Y scaling factor applied, updated in game loop
var ScaledTerminalHeight int
//ControlPresets : mappings between key presses and directions
var ControlPresets = []model.ControlScheme{
model.ControlScheme{
Name: "Arrow Keys",
Controls: map[termbox.Event]model.Direction{
termbox.Event{Type: termbox.EventKey, Key: termbox.KeyArrowUp}: model.Up,
termbox.Event{Type: termbox.EventKey, Key: termbox.KeyArrowDown}: model.Down,
termbox.Event{Type: termbox.EventKey, Key: termbox.KeyArrowLeft}: model.Left,
termbox.Event{Type: termbox.EventKey, Key: termbox.KeyArrowRight}: model.Right,
},
},
model.ControlScheme{
Name: "[W][S][A][D]",
Controls: map[termbox.Event]model.Direction{
termbox.Event{Type: termbox.EventKey, Ch: 'w'}: model.Up,
termbox.Event{Type: termbox.EventKey, Ch: 's'}: model.Down,
termbox.Event{Type: termbox.EventKey, Ch: 'a'}: model.Left,
termbox.Event{Type: termbox.EventKey, Ch: 'd'}: model.Right,
},
},
model.ControlScheme{
Name: "[I][J][K][L]",
Controls: map[termbox.Event]model.Direction{
termbox.Event{Type: termbox.EventKey, Ch: 'i'}: model.Up,
termbox.Event{Type: termbox.EventKey, Ch: 'k'}: model.Down,
termbox.Event{Type: termbox.EventKey, Ch: 'j'}: model.Left,
termbox.Event{Type: termbox.EventKey, Ch: 'l'}: model.Right,
},
},
model.ControlScheme{
Name: "[G][V][B][N]",
Controls: map[termbox.Event]model.Direction{
termbox.Event{Type: termbox.EventKey, Ch: 'g'}: model.Up,
termbox.Event{Type: termbox.EventKey, Ch: 'b'}: model.Down,
termbox.Event{Type: termbox.EventKey, Ch: 'v'}: model.Left,
termbox.Event{Type: termbox.EventKey, Ch: 'n'}: model.Right,
},
},
model.ControlScheme{
Name: "AI",
},
}
//DefaultPlayers : initial player objects to populate game state
var DefaultPlayers = []*model.Player{
&model.Player{
Id: 1,
Color: termbox.ColorRed,
Alive: true,
ControlScheme: ControlPresets[0],
},
&model.Player{
Id: 2,
Color: termbox.ColorBlue,
Alive: true,
ControlScheme: ControlPresets[1],
},
&model.Player{
Id: 3,
Color: termbox.ColorGreen,
Alive: true,
ControlScheme: ControlPresets[2],
},
&model.Player{
Id: 4,
Color: termbox.ColorYellow,
Alive: true,
ControlScheme: ControlPresets[3],
},
}