mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
Refactoring
This commit is contained in:
parent
80c666b266
commit
ab558db683
@ -76,21 +76,19 @@ func main() {
|
||||
game := &DemoGame{}
|
||||
device = graphics.NewDevice(screenWidth, screenHeight, screenScale,
|
||||
func(g *graphics.GraphicsContext, offscreen *graphics.Texture) {
|
||||
<-ch
|
||||
ticket := <-ch
|
||||
game.Draw(g, offscreen)
|
||||
ch<- true
|
||||
ch<- ticket
|
||||
})
|
||||
|
||||
go func() {
|
||||
const frameTime = time.Second / 60
|
||||
lastTime := time.Now()
|
||||
tick := time.Tick(frameTime)
|
||||
for {
|
||||
<-ch
|
||||
<-tick
|
||||
ticket := <-ch
|
||||
game.Update()
|
||||
ch<- true
|
||||
now := time.Now()
|
||||
time.Sleep(frameTime - now.Sub(lastTime))
|
||||
lastTime = now
|
||||
ch<- ticket
|
||||
}
|
||||
}()
|
||||
ch<- true
|
||||
|
@ -92,7 +92,3 @@ func NewTextureFromRGBA(image *image.RGBA) *Texture {
|
||||
func (texture *Texture) IsAvailable() bool {
|
||||
return texture.id != 0
|
||||
}
|
||||
|
||||
func init() {
|
||||
// TODO: Initialize OpenGL here?
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user