diff --git a/main.go b/main.go index 0da5fc7..8c13cde 100644 --- a/main.go +++ b/main.go @@ -2,7 +2,6 @@ package main import ( "bitbucket.org/hackerbots/botserv/protocol" - v "bitbucket.org/hackerbots/vector" "code.google.com/p/go.net/websocket" "flag" "fmt" @@ -105,21 +104,16 @@ func addPlayer(ws *websocket.Conn) { } log.Printf("%s eventually sent valid config: %+v", id, conf) - start_pos := v.Point2d{ - X: rand.Float64() * *width, - Y: rand.Float64() * *height, - } p := &player{ Robot: robot{ Stats: conf.Stats, - Position: start_pos, - MoveTo: start_pos, Id: id, Health: conf.Stats.Hp, Scanners: make([]scanner, 0)}, send: make(chan *boardstate), ws: ws, } + p.reset() g.register <- p defer func() { g.unregister <- p diff --git a/player.go b/player.go index 450bae0..665aa28 100644 --- a/player.go +++ b/player.go @@ -102,8 +102,8 @@ func (p *player) fire() { func (p *player) reset() { start_pos := v.Point2d{ - X: rand.Float64() * 800, - Y: rand.Float64() * 550, + X: rand.Float64() * *width, + Y: rand.Float64() * *height, } p.Robot.MoveTo = start_pos p.Robot.Position = start_pos