Refactoring

This commit is contained in:
Hajime Hoshi 2013-06-18 10:45:44 +09:00
parent 5b77d00e84
commit 80c666b266

View File

@ -76,22 +76,24 @@ func main() {
game := &DemoGame{}
device = graphics.NewDevice(screenWidth, screenHeight, screenScale,
func(g *graphics.GraphicsContext, offscreen *graphics.Texture) {
ch<- true
game.Draw(g, offscreen)
<-ch
game.Draw(g, offscreen)
ch<- true
})
go func() {
const frameTime = time.Second / 60
lastTime := time.Now()
for {
ch<- true
game.Update()
<-ch
time.Sleep(frameTime - time.Since(lastTime))
lastTime = time.Now()
game.Update()
ch<- true
now := time.Now()
time.Sleep(frameTime - now.Sub(lastTime))
lastTime = now
}
}()
ch<- true
C.glutMainLoop()
}