fixed initial position bug
This commit is contained in:
parent
7e3404095a
commit
7997b15c26
8
main.go
8
main.go
@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bitbucket.org/hackerbots/botserv/protocol"
|
"bitbucket.org/hackerbots/botserv/protocol"
|
||||||
v "bitbucket.org/hackerbots/vector"
|
|
||||||
"code.google.com/p/go.net/websocket"
|
"code.google.com/p/go.net/websocket"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -105,21 +104,16 @@ func addPlayer(ws *websocket.Conn) {
|
|||||||
}
|
}
|
||||||
log.Printf("%s eventually sent valid config: %+v", id, conf)
|
log.Printf("%s eventually sent valid config: %+v", id, conf)
|
||||||
|
|
||||||
start_pos := v.Point2d{
|
|
||||||
X: rand.Float64() * *width,
|
|
||||||
Y: rand.Float64() * *height,
|
|
||||||
}
|
|
||||||
p := &player{
|
p := &player{
|
||||||
Robot: robot{
|
Robot: robot{
|
||||||
Stats: conf.Stats,
|
Stats: conf.Stats,
|
||||||
Position: start_pos,
|
|
||||||
MoveTo: start_pos,
|
|
||||||
Id: id,
|
Id: id,
|
||||||
Health: conf.Stats.Hp,
|
Health: conf.Stats.Hp,
|
||||||
Scanners: make([]scanner, 0)},
|
Scanners: make([]scanner, 0)},
|
||||||
send: make(chan *boardstate),
|
send: make(chan *boardstate),
|
||||||
ws: ws,
|
ws: ws,
|
||||||
}
|
}
|
||||||
|
p.reset()
|
||||||
g.register <- p
|
g.register <- p
|
||||||
defer func() {
|
defer func() {
|
||||||
g.unregister <- p
|
g.unregister <- p
|
||||||
|
@ -102,8 +102,8 @@ func (p *player) fire() {
|
|||||||
|
|
||||||
func (p *player) reset() {
|
func (p *player) reset() {
|
||||||
start_pos := v.Point2d{
|
start_pos := v.Point2d{
|
||||||
X: rand.Float64() * 800,
|
X: rand.Float64() * *width,
|
||||||
Y: rand.Float64() * 550,
|
Y: rand.Float64() * *height,
|
||||||
}
|
}
|
||||||
p.Robot.MoveTo = start_pos
|
p.Robot.MoveTo = start_pos
|
||||||
p.Robot.Position = start_pos
|
p.Robot.Position = start_pos
|
||||||
|
Loading…
Reference in New Issue
Block a user