Add support for fixed object geometry
also updated config file
This commit is contained in:
+23
-1
@@ -64,6 +64,7 @@ func (c *Controller) StartGame(w http.ResponseWriter, req *http.Request) {
|
||||
requested_game_name := c.Idg.Hash()
|
||||
width, height := float64(c.Conf.Width), float64(c.Conf.Height)
|
||||
obstacleCount := 0
|
||||
obstacles := []Obstacle{}
|
||||
maxPoints := c.Conf.MaxPoints
|
||||
mode := "deathmatch"
|
||||
|
||||
@@ -90,6 +91,7 @@ func (c *Controller) StartGame(w http.ResponseWriter, req *http.Request) {
|
||||
width = float64(cfg.Width)
|
||||
height = float64(cfg.Height)
|
||||
obstacleCount = cfg.ObstacleCount
|
||||
obstacles = cfg.Obstacles
|
||||
maxPoints = cfg.MaxPoints
|
||||
mode = cfg.Mode
|
||||
}
|
||||
@@ -98,7 +100,27 @@ func (c *Controller) StartGame(w http.ResponseWriter, req *http.Request) {
|
||||
if g == nil {
|
||||
log.Printf("Game '%s' non-existant; making it now", requested_game_name)
|
||||
var err error
|
||||
g, err = NewGame(requested_game_name, width, height, obstacleCount, c.Conf.Tick, maxPoints, mode)
|
||||
g, err = NewGame(
|
||||
requested_game_name,
|
||||
width,
|
||||
height,
|
||||
c.Conf.Tick,
|
||||
maxPoints,
|
||||
mode,
|
||||
)
|
||||
g.obstacleCount = obstacleCount
|
||||
g.obstacles = obstacles
|
||||
g.defaultObstacles = obstacles
|
||||
if len(g.defaultObstacles) == 0 {
|
||||
g.obstacles = GenerateObstacles(
|
||||
g.obstacleCount,
|
||||
g.width,
|
||||
g.height,
|
||||
)
|
||||
} else {
|
||||
g.obstacles = c.Conf.Obstacles
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Printf("problem creating game: %s: %s", requested_game_name, err)
|
||||
b, _ := json.Marshal(NewFailure("game creation failure"))
|
||||
|
||||
Reference in New Issue
Block a user