fixed initial position bug

This commit is contained in:
Stephen McQuay 2013-08-19 23:25:08 -07:00
parent 7e3404095a
commit 7997b15c26
2 changed files with 3 additions and 9 deletions

View File

@ -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

View File

@ -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