Refactoring

This commit is contained in:
Hajime Hoshi 2013-06-21 23:22:46 +09:00
parent b84cc9a57b
commit 88eeb6d65d

View File

@ -31,7 +31,13 @@ func NewSprite(screenWidth, screenHeight int,
vx: rand.Intn(2)*2 - 1,
vy: rand.Intn(2)*2 - 1,
}
go func() {
go sprite.update(screenWidth, screenHeight)
return sprite
}
func (sprite *Sprite) update(screenWidth, screenHeight int) {
maxX := screenWidth - sprite.texture.Width
maxY := screenHeight - sprite.texture.Height
for {
<-sprite.ch
sprite.x += sprite.vx
@ -44,8 +50,6 @@ func NewSprite(screenWidth, screenHeight int,
}
sprite.ch <- true
}
}()
return sprite
}
func (sprite *Sprite) Update() {