mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Refactoring
This commit is contained in:
parent
b84cc9a57b
commit
88eeb6d65d
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user