From e99f2f9f69a117958cd94c2992bad9d5743f2351 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 17 Jul 2018 22:41:27 +0900 Subject: [PATCH] ui: Rename TPS -> MaxTPS --- ebitenutil/gif.go | 2 +- examples/alphablending/main.go | 2 +- examples/blocks/blocks/gamepadscene.go | 2 +- examples/blocks/blocks/gamescene.go | 2 +- examples/chipmunk/main.go | 2 +- examples/font/main.go | 2 +- examples/paint/main.go | 2 +- examples/pcm/main.go | 2 +- examples/windowsize/main.go | 6 +++--- graphicscontext.go | 2 +- run.go | 14 +++++++------- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ebitenutil/gif.go b/ebitenutil/gif.go index b2205134d..8126b929f 100644 --- a/ebitenutil/gif.go +++ b/ebitenutil/gif.go @@ -51,7 +51,7 @@ func init() { } func (r *recorder) delay() int { - delay := 100 * r.skips / ebiten.TPS() + delay := 100 * r.skips / ebiten.MaxTPS() if delay < 2 { return 2 } diff --git a/examples/alphablending/main.go b/examples/alphablending/main.go index b1c906896..7f667f58d 100644 --- a/examples/alphablending/main.go +++ b/examples/alphablending/main.go @@ -39,7 +39,7 @@ var ( func update(screen *ebiten.Image) error { count++ - count %= ebiten.TPS() * 10 + count %= ebiten.MaxTPS() * 10 diff := float64(count) * 0.2 switch { case 480 < count: diff --git a/examples/blocks/blocks/gamepadscene.go b/examples/blocks/blocks/gamepadscene.go index afc58f67e..b3c116d03 100644 --- a/examples/blocks/blocks/gamepadscene.go +++ b/examples/blocks/blocks/gamepadscene.go @@ -66,7 +66,7 @@ func (s *GamepadScene) Update(state *GameState) error { if state.Input.gamepadConfig.Scan(gamepadID, b) { s.currentIndex++ if s.currentIndex == len(virtualGamepadButtons) { - s.countAfterSetting = ebiten.TPS() + s.countAfterSetting = ebiten.MaxTPS() } } return nil diff --git a/examples/blocks/blocks/gamescene.go b/examples/blocks/blocks/gamescene.go index 0ee705b1f..6226d07ad 100644 --- a/examples/blocks/blocks/gamescene.go +++ b/examples/blocks/blocks/gamescene.go @@ -242,7 +242,7 @@ func (s *GameScene) Update(state *GameState) error { return nil } - maxLandingCount := ebiten.TPS() + maxLandingCount := ebiten.MaxTPS() if s.currentPiece == nil { s.initCurrentPiece(s.choosePiece()) } diff --git a/examples/chipmunk/main.go b/examples/chipmunk/main.go index 65dd03ca8..416836efa 100644 --- a/examples/chipmunk/main.go +++ b/examples/chipmunk/main.go @@ -38,7 +38,7 @@ func init() { } func update(screen *ebiten.Image) error { - space.Step(1.0 / float64(ebiten.TPS())) + space.Step(1.0 / float64(ebiten.MaxTPS())) if ebiten.IsDrawingSkipped() { return nil diff --git a/examples/font/main.go b/examples/font/main.go index 4257308bd..55b690325 100644 --- a/examples/font/main.go +++ b/examples/font/main.go @@ -117,7 +117,7 @@ func init() { func update(screen *ebiten.Image) error { // Change the text color for each second. - if counter%ebiten.TPS() == 0 { + if counter%ebiten.MaxTPS() == 0 { kanjiText = []rune{} for j := 0; j < 4; j++ { for i := 0; i < 8; i++ { diff --git a/examples/paint/main.go b/examples/paint/main.go index 25baf1e62..3444eff01 100644 --- a/examples/paint/main.go +++ b/examples/paint/main.go @@ -66,7 +66,7 @@ func paint(canvas *ebiten.Image, x, y int) { op.GeoM.Translate(float64(x), float64(y)) // Scale the color and rotate the hue so that colors vary on each frame. op.ColorM.Scale(1.0, 0.50, 0.125, 1.0) - tps := ebiten.TPS() + tps := ebiten.MaxTPS() theta := 2.0 * math.Pi * float64(count%tps) / float64(tps) op.ColorM.RotateHue(theta) canvas.DrawImage(brushImage, op) diff --git a/examples/pcm/main.go b/examples/pcm/main.go index 65e064850..854fb72bf 100644 --- a/examples/pcm/main.go +++ b/examples/pcm/main.go @@ -119,7 +119,7 @@ func playNote(scoreIndex int) rune { } const vol = 1.0 / 16.0 - size := 30 * sampleRate / ebiten.TPS() + size := 30 * sampleRate / ebiten.MaxTPS() l := make([]int16, size) r := make([]int16, size) square(l, vol, freq, 0.25) diff --git a/examples/windowsize/main.go b/examples/windowsize/main.go index f34dd89db..6ec0811eb 100644 --- a/examples/windowsize/main.go +++ b/examples/windowsize/main.go @@ -87,7 +87,7 @@ func update(screen *ebiten.Image) error { runnableInBackground := ebiten.IsRunnableInBackground() cursorVisible := ebiten.IsCursorVisible() vsyncEnabled := ebiten.IsVsyncEnabled() - tps := ebiten.TPS() + tps := ebiten.MaxTPS() if inpututil.IsKeyJustPressed(ebiten.KeyUp) { screenHeight += d @@ -176,8 +176,8 @@ func update(screen *ebiten.Image) error { x, y := ebiten.CursorPosition() tpsStr := "Uncapped" - if tps := ebiten.TPS(); tps != ebiten.UncappedTPS { - tpsStr = fmt.Sprintf("%d", tps) + if maxTPS := ebiten.MaxTPS(); maxTPS != ebiten.UncappedTPS { + tpsStr = fmt.Sprintf("%d", maxTPS) } msg := fmt.Sprintf(`Press arrow keys to change the window size Press S key to change the window scale diff --git a/graphicscontext.go b/graphicscontext.go index 33da41a32..3478088f5 100644 --- a/graphicscontext.go +++ b/graphicscontext.go @@ -82,7 +82,7 @@ func (c *graphicsContext) initializeIfNeeded() error { } func (c *graphicsContext) Update(afterFrameUpdate func()) error { - tps := int(TPS()) + tps := int(MaxTPS()) updateCount := clock.Update(tps) if tps == UncappedTPS { updateCount = 1 diff --git a/run.go b/run.go index 9aa280aef..e073edb57 100644 --- a/run.go +++ b/run.go @@ -48,11 +48,11 @@ func CurrentFPS() float64 { var ( isDrawingSkipped = int32(0) - currentTPS = int32(0) + currentMaxTPS = int32(0) ) func init() { - atomic.StoreInt32(¤tTPS, DefaultTPS) + atomic.StoreInt32(¤tMaxTPS, DefaultTPS) } func setDrawingSkipped(skipped bool) { @@ -557,11 +557,11 @@ func SetVsyncEnabled(enabled bool) { ui.SetVsyncEnabled(enabled) } -// TPS returns the current TPS. +// MaxTPS returns the current maximum TPS. // -// TPS is concurrent-safe. -func TPS() int { - return int(atomic.LoadInt32(¤tTPS)) +// MaxTPS is concurrent-safe. +func MaxTPS() int { + return int(atomic.LoadInt32(¤tMaxTPS)) } // UncappedTPS is a special TPS value that means the game doesn't have limitation on TPS. @@ -579,5 +579,5 @@ func SetMaxTPS(tps int) { if tps < 0 && tps != UncappedTPS { panic("ebiten: tps must be >= 0 or UncappedTPS") } - atomic.StoreInt32(¤tTPS, int32(tps)) + atomic.StoreInt32(¤tMaxTPS, int32(tps)) }