mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
Use the term 'TPS' ticks per second
This commit is contained in:
parent
bbb777eecc
commit
88e6768a30
@ -64,7 +64,7 @@ func updateFPS(now int64) {
|
||||
|
||||
// Update updates the inner clock state and returns an integer value
|
||||
// indicating how many game frames the game should update.
|
||||
func Update(logicFPS int) int {
|
||||
func Update(tps int) int {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
@ -95,15 +95,15 @@ func Update(logicFPS int) int {
|
||||
// Let's force to sync the game time with the system clock.
|
||||
syncWithSystemClock = true
|
||||
} else {
|
||||
count = int(diff * int64(logicFPS) / int64(time.Second))
|
||||
count = int(diff * int64(tps) / int64(time.Second))
|
||||
}
|
||||
|
||||
// Stabilize FPS.
|
||||
// Without this adjustment, count can be unstable like 0, 2, 0, 2, ...
|
||||
if count == 0 && (int64(time.Second)/int64(logicFPS)/2) < diff {
|
||||
if count == 0 && (int64(time.Second)/int64(tps)/2) < diff {
|
||||
count = 1
|
||||
}
|
||||
if count == 2 && (int64(time.Second)/int64(logicFPS)*3/2) > diff {
|
||||
if count == 2 && (int64(time.Second)/int64(tps)*3/2) > diff {
|
||||
count = 1
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ func Update(logicFPS int) int {
|
||||
if syncWithSystemClock {
|
||||
lastSystemTime = n
|
||||
} else {
|
||||
lastSystemTime += int64(count) * int64(time.Second) / int64(logicFPS)
|
||||
lastSystemTime += int64(count) * int64(time.Second) / int64(tps)
|
||||
}
|
||||
|
||||
updateFPS(n)
|
||||
|
14
run.go
14
run.go
@ -30,13 +30,15 @@ import (
|
||||
)
|
||||
|
||||
// FPS represents how many times game updating happens in a second (60).
|
||||
//
|
||||
// BUG: This actually represents TPS, not FPS.
|
||||
const FPS = 60
|
||||
|
||||
// CurrentFPS returns the current number of frames per second of rendering.
|
||||
//
|
||||
// The returned value represents how many times rendering happens in a second and
|
||||
// NOT how many times logical game updating (a passed function to Run) happens.
|
||||
// Note that logical game updating is assured to happen 60 times in a second.
|
||||
// The returned value FPS (frames per second) that represents how many times rendering happens in a
|
||||
// second and NOT TPS (ticks per second) that represents how many times logical game updating (a
|
||||
// passed function to Run) happens in a second.
|
||||
//
|
||||
// CurrentFPS is concurrent-safe.
|
||||
func CurrentFPS() float64 {
|
||||
@ -250,8 +252,10 @@ func (i *imageDumper) update(screen *Image) error {
|
||||
// Run must be called from the OS main thread.
|
||||
// Note that Ebiten bounds the main goroutine to the main OS thread by runtime.LockOSThread.
|
||||
//
|
||||
// The given function f is guaranteed to be called 60 times a second
|
||||
// even if a rendering frame is skipped.
|
||||
// Ebiten tries to call f 60 times a second. In other words,
|
||||
// TPS (ticks per second) is 60.
|
||||
// This is not related to framerate (display's frashrate).
|
||||
//
|
||||
// f is not called when the window is in background by default.
|
||||
// This setting is configurable with SetRunnableInBackground.
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user