From c28bcc26fc39f2240e2b150bf205392dbded2605 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 22 Jul 2021 22:44:58 +0900 Subject: [PATCH] internal/clock: Rename UncappedTPS -> SyncWithFPS Closes #1726 --- examples/windowsize/main.go | 8 ++++---- internal/clock/clock.go | 8 ++++---- run.go | 17 +++++++++++------ 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/examples/windowsize/main.go b/examples/windowsize/main.go index 44410325c..48680c51e 100644 --- a/examples/windowsize/main.go +++ b/examples/windowsize/main.go @@ -209,14 +209,14 @@ func (g *game) Update() error { } if inpututil.IsKeyJustPressed(ebiten.KeyT) { switch tps { - case ebiten.UncappedTPS: + case ebiten.SyncWithFPS: tps = 30 case 30: tps = 60 case 60: tps = 120 case 120: - tps = ebiten.UncappedTPS + tps = ebiten.SyncWithFPS default: panic("not reached") } @@ -293,8 +293,8 @@ func (g *game) Draw(screen *ebiten.Image) { wx, wy := ebiten.WindowPosition() minw, minh, maxw, maxh := ebiten.WindowSizeLimits() cx, cy := ebiten.CursorPosition() - tpsStr := "Uncapped" - if t := ebiten.MaxTPS(); t != ebiten.UncappedTPS { + tpsStr := "Sync with FPS" + if t := ebiten.MaxTPS(); t != ebiten.SyncWithFPS { tpsStr = fmt.Sprintf("%d", t) } diff --git a/internal/clock/clock.go b/internal/clock/clock.go index 8b17d1a03..480dc6e38 100644 --- a/internal/clock/clock.go +++ b/internal/clock/clock.go @@ -125,13 +125,13 @@ func updateFPSAndTPS(now int64, count int) { tpsCount = 0 } -const UncappedTPS = -1 +const SyncWithFPS = -1 // Update updates the inner clock state and returns an integer value // indicating how many times the game should update based on given tps. // tps represents TPS (ticks per second). -// If tps is UncappedTPS, Update always returns 1. -// If tps <= 0 and not UncappedTPS, Update always returns 0. +// If tps is SyncWithFPS, Update always returns 1. +// If tps <= 0 and not SyncWithFPS, Update always returns 0. // // Update is expected to be called per frame. func Update(tps int) int { @@ -146,7 +146,7 @@ func Update(tps int) int { lastNow = n c := 0 - if tps == UncappedTPS { + if tps == SyncWithFPS { c = 1 } else if tps > 0 { c = calcCountFromTPS(int64(tps), n) diff --git a/run.go b/run.go index 676e1b5d1..ddb33f33e 100644 --- a/run.go +++ b/run.go @@ -364,20 +364,25 @@ func CurrentTPS() float64 { return clock.CurrentTPS() } -// UncappedTPS is a special TPS value that means the game doesn't have limitation on TPS. -const UncappedTPS = clock.UncappedTPS +// SyncWithFPS is a special TPS value that means TPS syncs with FPS. +const SyncWithFPS = clock.SyncWithFPS + +// UncappedTPS is a special TPS value that means TPS syncs with FPS. +// +// Deprecated: as of v2.2. Use SyncWithFPS instead. +const UncappedTPS = SyncWithFPS // SetMaxTPS sets the maximum TPS (ticks per second), // that represents how many updating function is called per second. // The initial value is 60. // -// If tps is UncappedTPS, TPS is uncapped and the game is updated per frame. -// If tps is negative but not UncappedTPS, SetMaxTPS panics. +// If tps is SyncWithFPS, TPS is uncapped and the game is updated per frame. +// If tps is negative but not SyncWithFPS, SetMaxTPS panics. // // SetMaxTPS is concurrent-safe. func SetMaxTPS(tps int) { - if tps < 0 && tps != UncappedTPS { - panic("ebiten: tps must be >= 0 or UncappedTPS") + if tps < 0 && tps != SyncWithFPS { + panic("ebiten: tps must be >= 0 or SyncWithFPS") } atomic.StoreInt32(¤tMaxTPS, int32(tps)) }