Adding collisions and acceleration. Fixing splosions and projectiles.

This commit is contained in:
Fraser Graham
2013-09-27 01:30:26 -07:00
parent 472e2011b9
commit 92a2040d70
2 changed files with 80 additions and 7 deletions
+8 -2
View File
@@ -92,7 +92,7 @@ func (g *game) run() {
robots_remaining++
// TODO: measure if this would be better to go and wait ...
p.scan(g.players)
p.nudge()
p.nudge(g)
if p.Robot.FireAt != nil {
proj := p.fire(g.projectiles)
if proj != nil {
@@ -109,7 +109,10 @@ func (g *game) run() {
)
for s := range g.splosions {
// XXX: s.tick()
s.Tick()
if !s.Alive() {
delete(g.splosions, s)
}
payload.Splosions = append(payload.Splosions, *s)
}
@@ -148,6 +151,7 @@ func (g *game) run() {
}
func (g *game) nudgeProjectiles() (rprojectiles []bot.Projectile) {
rprojectiles = make([]bot.Projectile, 0)
for p := range g.projectiles {
newPos := v.Move(p.Position, p.MoveTo, float64(p.Speed), delta)
@@ -191,6 +195,8 @@ func (g *game) nudgeProjectiles() (rprojectiles []bot.Projectile) {
}
p.Position.X = newPos.X
p.Position.Y = newPos.Y
rprojectiles = append(rprojectiles, *p)
}
return
}