moved a bunch of logic out of run and into functions of the game, for a cleaner separation of functionality.

Also, removed a bunch of overly verbose logging
This commit is contained in:
Fraser Graham
2013-10-20 21:15:23 -07:00
parent 776a7eee98
commit 200afffa7f
6 changed files with 84 additions and 87 deletions
+8 -2
View File
@@ -78,7 +78,8 @@ func (p *player) checkCollisions(g *game, move_vector v.Vector2d) (bool, v.Point
return collision, intersection_point
}
func (p *player) nudge(g *game) {
func (p *player) Tick(g *game) {
p.scan(g.players)
// Adjust Speed
if p.Robot.Speed < p.Robot.TargetSpeed {
@@ -94,7 +95,6 @@ func (p *player) nudge(g *game) {
if current_heading.Mag() == 0 {
// We may have been stopped before this and had no heading
current_heading = p.Robot.MoveTo.Sub(p.Robot.Position).Normalize()
log.Printf("Heading WAS zero, is now %v", current_heading)
}
// Where do we WANT to be heading?
@@ -137,6 +137,12 @@ func (p *player) nudge(g *game) {
}
}
if p.Robot.FireAt != nil {
proj := p.fire(g.projectiles, g.turn)
if proj != nil {
g.projectiles[proj] = true
}
}
}
func (p *player) scan(players map[*player]bool) {