Add support for fixed object geometry

also updated config file
This commit is contained in:
sm
2014-05-11 21:49:06 -07:00
parent 961cf5d7da
commit c9dfa27320
5 changed files with 54 additions and 10 deletions
+23 -1
View File
@@ -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"))