Got game working again

I just moved some old code into the game struct; probably still merits some
cleanup in the main loop.
This commit is contained in:
sm
2013-09-20 12:15:10 -06:00
parent f175e45c63
commit f8378cf89b
3 changed files with 59 additions and 61 deletions
+3 -8
View File
@@ -12,13 +12,7 @@ type player struct {
ws *websocket.Conn
Robot bot.Robot
send chan *bot.Boardstate
Instruction instruction
}
type instruction struct {
MoveTo *v.Point2d `json:"move_to,omitempty"`
FireAt *v.Point2d `json:"fire_at,omitempty"`
Stats bot.Stats `json:"stats"`
Instruction bot.Instruction
}
func (p *player) sender() {
@@ -36,7 +30,7 @@ func (p *player) recv() {
for {
// XXX: need to mark myself as having received something, also binding
// such action to a particular game turn ID
var msg instruction
var msg bot.Instruction
err := websocket.JSON.Receive(p.ws, &msg)
if err != nil {
// TODO: perhaps we could be a bit more precise in the handling of
@@ -62,6 +56,7 @@ func (p *player) recv() {
}
func (p *player) nudge() {
// XXX: we must take into account going past our p.Robot.MoveTo ...
newPos := v.Move(p.Robot.Position, *p.Robot.MoveTo, p.Robot.Stats.Speed, delta)
p.Robot.Position.X = newPos.X
p.Robot.Position.Y = newPos.Y