Browse Source

Renamed obstacle -> obstacle count

Stephen McQuay 5 years ago
parent
commit
db28bfea11
3 changed files with 26 additions and 26 deletions
  1. 22
    22
      config.go
  2. 3
    3
      control.go
  3. 1
    1
      protocol.go

+ 22
- 22
config.go View File

@@ -15,24 +15,24 @@ import (
15 15
 // ways (json POSTed to server, config file, constants) and are typically owned
16 16
 // by a Controller.
17 17
 type Config struct {
18
-	Tick      int     `json:"tick"` // ms
19
-	Timescale float32 `json:"timescale"`
20
-	Delta     float32 `json:"delta"`
21
-	Width     int     `json:"width"`
22
-	Height    int     `json:"height"`
23
-	Obstacles int     `json:"obstacles"`
24
-	MaxPoints int     `json:"max_points"`
25
-	Mode      string  `json:"mode"`
18
+	Tick          int     `json:"tick"` // ms
19
+	Timescale     float32 `json:"timescale"`
20
+	Delta         float32 `json:"delta"`
21
+	Width         int     `json:"width"`
22
+	Height        int     `json:"height"`
23
+	ObstacleCount int     `json:"obstacle_count"`
24
+	MaxPoints     int     `json:"max_points"`
25
+	Mode          string  `json:"mode"`
26 26
 }
27 27
 
28 28
 const (
29
-	TICK         = 60  // ms, this is how often physics is updated
30
-	TIMESCALE    = 1.0 // this tweaks the temporal duration of a TICK
31
-	WIDTH        = 800
32
-	HEIGHT       = 550
33
-	OBSTACLES    = 10
34
-	MAX_POINTS   = 500 // allowing for 50 pts in every category
35
-	DEFAULT_MODE = "deathmatch"
29
+	TICK           = 60  // ms, this is how often physics is updated
30
+	TIMESCALE      = 1.0 // this tweaks the temporal duration of a TICK
31
+	WIDTH          = 800
32
+	HEIGHT         = 550
33
+	OBSTACLE_COUNT = 5
34
+	MAX_POINTS     = 500 // allowing for 50 pts in every category
35
+	DEFAULT_MODE   = "deathmatch"
36 36
 )
37 37
 
38 38
 // LoadConfig takes the location of a json file that contains values desired to
@@ -41,13 +41,13 @@ const (
41 41
 // followed by constants defined above.
42 42
 func LoadConfig(filename string) (Config, error) {
43 43
 	c := Config{
44
-		Tick:      TICK,
45
-		Timescale: TIMESCALE,
46
-		Width:     WIDTH,
47
-		Height:    HEIGHT,
48
-		Obstacles: OBSTACLES,
49
-		MaxPoints: MAX_POINTS,
50
-		Mode:      DEFAULT_MODE,
44
+		Tick:          TICK,
45
+		Timescale:     TIMESCALE,
46
+		Width:         WIDTH,
47
+		Height:        HEIGHT,
48
+		ObstacleCount: OBSTACLE_COUNT,
49
+		MaxPoints:     MAX_POINTS,
50
+		Mode:          DEFAULT_MODE,
51 51
 	}
52 52
 	u, err := user.Current()
53 53
 	if err != nil {

+ 3
- 3
control.go View File

@@ -63,7 +63,7 @@ func (c *Controller) StartGame(w http.ResponseWriter, req *http.Request) {
63 63
 
64 64
 	requested_game_name := c.Idg.Hash()
65 65
 	width, height := float32(c.Conf.Width), float32(c.Conf.Height)
66
-	obstacles := 0
66
+	obstacleCount := 0
67 67
 	maxPoints := c.Conf.MaxPoints
68 68
 	mode := "deathmatch"
69 69
 
@@ -89,7 +89,7 @@ func (c *Controller) StartGame(w http.ResponseWriter, req *http.Request) {
89 89
 		requested_game_name = cfg.Name
90 90
 		width = float32(cfg.Width)
91 91
 		height = float32(cfg.Height)
92
-		obstacles = cfg.Obstacles
92
+		obstacleCount = cfg.ObstacleCount
93 93
 		maxPoints = cfg.MaxPoints
94 94
 		mode = cfg.Mode
95 95
 	}
@@ -98,7 +98,7 @@ func (c *Controller) StartGame(w http.ResponseWriter, req *http.Request) {
98 98
 	if g == nil {
99 99
 		log.Printf("Game '%s' non-existant; making it now", requested_game_name)
100 100
 		var err error
101
-		g, err = NewGame(requested_game_name, width, height, obstacles, c.Conf.Tick, maxPoints, mode)
101
+		g, err = NewGame(requested_game_name, width, height, obstacleCount, c.Conf.Tick, maxPoints, mode)
102 102
 		if err != nil {
103 103
 			log.Printf("problem creating game: %s: %s", requested_game_name, err)
104 104
 			b, _ := json.Marshal(NewFailure("game creation failure"))

+ 1
- 1
protocol.go View File

@@ -177,7 +177,7 @@ func (c *Controller) AddPlayer(ws *websocket.Conn) {
177 177
 			gid.Id,
178 178
 			float32(c.Conf.Width),
179 179
 			float32(c.Conf.Height),
180
-			c.Conf.Obstacles,
180
+			c.Conf.ObstacleCount,
181 181
 			c.Conf.Tick,
182 182
 			c.Conf.MaxPoints,
183 183
 			"",

Loading…
Cancel
Save