mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
ui: Use integers as much as possible
This commit is contained in:
parent
328900ec80
commit
884719264e
9
run.go
9
run.go
@ -199,9 +199,10 @@ func Run(f func(*Image) error, width, height, scale int, title string) error {
|
|||||||
currentRunContext.setRunningSlowly(false)
|
currentRunContext.setRunningSlowly(false)
|
||||||
beforeForUpdate = now
|
beforeForUpdate = now
|
||||||
} else {
|
} else {
|
||||||
t := float64(now-beforeForUpdate) * FPS / float64(time.Second)
|
t := now - beforeForUpdate
|
||||||
currentRunContext.setRunningSlowly(t >= 2.5)
|
currentRunContext.setRunningSlowly(t*FPS >= int64(time.Second*5/2))
|
||||||
for i := 0; i < int(t); i++ {
|
tt := int(t * FPS / int64(time.Second))
|
||||||
|
for i := 0; i < tt; i++ {
|
||||||
if err := ui.CurrentUI().DoEvents(); err != nil {
|
if err := ui.CurrentUI().DoEvents(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -213,7 +214,7 @@ func Run(f func(*Image) error, width, height, scale int, title string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui.CurrentUI().SwapBuffers()
|
ui.CurrentUI().SwapBuffers()
|
||||||
beforeForUpdate += int64(t) * int64(time.Second/FPS)
|
beforeForUpdate += int64(tt) * int64(time.Second) / FPS
|
||||||
frames++
|
frames++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user