mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
ebiten: rename TPS functions
* SetMaxTPS() -> SetTPS() * MaxTPS() -> TPS() * CurrentTPS() -> ActualTPS() * CurrentFPS() -> ActualFPS() Closes #2071
This commit is contained in:
parent
356c625601
commit
0f52381580
@ -270,7 +270,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
|
||||
// Draw the message.
|
||||
tutorial := "Space: Move forward\nLeft/Right: Rotate"
|
||||
msg := fmt.Sprintf("TPS: %0.2f\nFPS: %0.2f\n%s", ebiten.CurrentTPS(), ebiten.CurrentFPS(), tutorial)
|
||||
msg := fmt.Sprintf("TPS: %0.2f\nFPS: %0.2f\n%s", ebiten.ActualTPS(), ebiten.ActualFPS(), tutorial)
|
||||
ebitenutil.DebugPrint(screen, msg)
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ type Game struct {
|
||||
|
||||
func (g *Game) Update() error {
|
||||
g.count++
|
||||
g.count %= ebiten.MaxTPS() * 10
|
||||
g.count %= ebiten.TPS() * 10
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -369,7 +369,7 @@ Press U to switch the runnable-on-unfocused state
|
||||
Press A to switch Ogg and MP3 (Current: %s)
|
||||
Current Time: %s
|
||||
Current Volume: %d/128
|
||||
Type: %s`, ebiten.CurrentTPS(), p.musicType,
|
||||
Type: %s`, ebiten.ActualTPS(), p.musicType,
|
||||
currentTimeStr, int(p.audioPlayer.Volume()*128), p.musicType)
|
||||
ebitenutil.DebugPrint(screen, msg)
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ audio.NewInfiniteLoopWithIntro.
|
||||
|
||||
Intro: 0[s] - %[2]d[s]
|
||||
Loop: %[2]d[s] - %[3]d[s]
|
||||
Current: %0.2[4]f[s]`, ebiten.CurrentTPS(), introLengthInSecond, introLengthInSecond+loopLengthInSecond, float64(pos)/float64(time.Second))
|
||||
Current: %0.2[4]f[s]`, ebiten.ActualTPS(), introLengthInSecond, introLengthInSecond+loopLengthInSecond, float64(pos)/float64(time.Second))
|
||||
ebitenutil.DebugPrint(screen, msg)
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
This is an example using
|
||||
stereo audio panning.
|
||||
Current: %0.2f[s]
|
||||
Panning: %.2f`, ebiten.CurrentTPS(), float64(pos)/float64(time.Second), g.panning)
|
||||
Panning: %.2f`, ebiten.ActualTPS(), float64(pos)/float64(time.Second), g.panning)
|
||||
ebitenutil.DebugPrint(screen, msg)
|
||||
|
||||
// draw image to show where the sound is at related to the screen
|
||||
|
@ -68,7 +68,7 @@ func (s *GamepadScene) Update(state *GameState) error {
|
||||
if state.Input.gamepadConfig.Scan(b) {
|
||||
s.currentIndex++
|
||||
if s.currentIndex == len(virtualGamepadButtons) {
|
||||
s.countAfterSetting = ebiten.MaxTPS()
|
||||
s.countAfterSetting = ebiten.TPS()
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
@ -238,7 +238,7 @@ func (s *GameScene) Update(state *GameState) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
maxLandingCount := ebiten.MaxTPS()
|
||||
maxLandingCount := ebiten.TPS()
|
||||
if s.currentPiece == nil {
|
||||
s.initCurrentPiece(s.choosePiece())
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
worldX, worldY := g.camera.ScreenToWorld(ebiten.CursorPosition())
|
||||
ebitenutil.DebugPrint(
|
||||
screen,
|
||||
fmt.Sprintf("TPS: %0.2f\nMove (WASD/Arrows)\nZoom (QE)\nRotate (R)\nReset (Space)", ebiten.CurrentTPS()),
|
||||
fmt.Sprintf("TPS: %0.2f\nMove (WASD/Arrows)\nZoom (QE)\nRotate (R)\nReset (Space)", ebiten.ActualTPS()),
|
||||
)
|
||||
|
||||
ebitenutil.DebugPrintAt(
|
||||
|
@ -91,7 +91,7 @@ func NewGame() *Game {
|
||||
}
|
||||
|
||||
func (g *Game) Update() error {
|
||||
g.space.Step(1.0 / float64(ebiten.MaxTPS()))
|
||||
g.space.Step(1.0 / float64(ebiten.TPS()))
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
screen.DrawImage(dot, op)
|
||||
})
|
||||
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.CurrentTPS()))
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.ActualTPS()))
|
||||
}
|
||||
|
||||
func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
|
||||
|
@ -312,7 +312,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
|
||||
scoreStr := fmt.Sprintf("%04d", g.score())
|
||||
text.Draw(screen, scoreStr, arcadeFont, screenWidth-len(scoreStr)*fontSize, fontSize, color.White)
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.CurrentTPS()))
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.ActualTPS()))
|
||||
}
|
||||
|
||||
func (g *Game) pipeAt(tileX int) (tileY int, ok bool) {
|
||||
|
@ -129,7 +129,7 @@ type Game struct {
|
||||
|
||||
func (g *Game) Update() error {
|
||||
// Change the text color for each second.
|
||||
if g.counter%ebiten.MaxTPS() == 0 {
|
||||
if g.counter%ebiten.TPS() == 0 {
|
||||
g.kanjiText = ""
|
||||
for j := 0; j < 4; j++ {
|
||||
for i := 0; i < 8; i++ {
|
||||
@ -151,7 +151,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
const x = 20
|
||||
|
||||
// Draw info
|
||||
msg := fmt.Sprintf("TPS: %0.2f", ebiten.CurrentTPS())
|
||||
msg := fmt.Sprintf("TPS: %0.2f", ebiten.ActualTPS())
|
||||
text.Draw(screen, msg, mplusNormalFont, x, 40, color.White)
|
||||
|
||||
// Draw the sample text
|
||||
|
@ -95,7 +95,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
}
|
||||
}
|
||||
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.CurrentTPS()))
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.ActualTPS()))
|
||||
}
|
||||
|
||||
func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
|
||||
|
@ -151,7 +151,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
g.renderLevel(screen)
|
||||
|
||||
// Print game info.
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("KEYS WASD EC R\nFPS %0.0f\nTPS %0.0f\nSCA %0.2f\nPOS %0.0f,%0.0f", ebiten.CurrentFPS(), ebiten.CurrentTPS(), g.camScale, g.camX, g.camY))
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("KEYS WASD EC R\nFPS %0.0f\nTPS %0.0f\nSCA %0.2f\nPOS %0.0f,%0.0f", ebiten.ActualFPS(), ebiten.ActualTPS(), g.camScale, g.camX, g.camY))
|
||||
}
|
||||
|
||||
// Layout is called when the Game's layout changes.
|
||||
|
@ -65,7 +65,7 @@ func (g *Game) Update() error {
|
||||
|
||||
func (g *Game) Draw(screen *ebiten.Image) {
|
||||
screen.ReplacePixels(g.noiseImage.Pix)
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f\nFPS: %0.2f", ebiten.CurrentTPS(), ebiten.CurrentFPS()))
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f\nFPS: %0.2f", ebiten.ActualTPS(), ebiten.ActualFPS()))
|
||||
}
|
||||
|
||||
func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
|
||||
|
@ -100,7 +100,7 @@ func (g *Game) 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.MaxTPS()
|
||||
tps := ebiten.TPS()
|
||||
theta := 2.0 * math.Pi * float64(g.count%tps) / float64(tps)
|
||||
op.ColorM.RotateHue(theta)
|
||||
canvas.DrawImage(brushImage, op)
|
||||
|
@ -164,7 +164,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
s.draw(screen)
|
||||
}
|
||||
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f\nSprites: %d", ebiten.CurrentTPS(), g.sprites.Len()))
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f\nSprites: %d", ebiten.ActualTPS(), g.sprites.Len()))
|
||||
}
|
||||
|
||||
func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
|
||||
|
@ -124,7 +124,7 @@ func (g *Game) playNote(scoreIndex int) rune {
|
||||
}
|
||||
|
||||
const vol = 1.0 / 16.0
|
||||
size := (ebiten.MaxTPS()/2 - 2) * sampleRate / ebiten.MaxTPS()
|
||||
size := (ebiten.TPS()/2 - 2) * sampleRate / ebiten.TPS()
|
||||
l := make([]int16, size)
|
||||
r := make([]int16, size)
|
||||
square(l, vol, freq, 0.25)
|
||||
|
@ -229,7 +229,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
screen.Fill(color.RGBA{0x80, 0x80, 0xc0, 0xff})
|
||||
screen.DrawImage(pianoImage, nil)
|
||||
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.CurrentTPS()))
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.ActualTPS()))
|
||||
}
|
||||
|
||||
func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
|
||||
|
@ -153,7 +153,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
g.gopher.draw(screen)
|
||||
|
||||
// Show the message
|
||||
msg := fmt.Sprintf("TPS: %0.2f\nPress the space key to jump.", ebiten.CurrentTPS())
|
||||
msg := fmt.Sprintf("TPS: %0.2f\nPress the space key to jump.", ebiten.ActualTPS())
|
||||
ebitenutil.DebugPrint(screen, msg)
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
}
|
||||
screen.DrawTriangles(g.vertices, indices, emptyImage.SubImage(image.Rect(1, 1, 2, 2)).(*ebiten.Image), op)
|
||||
|
||||
msg := fmt.Sprintf("TPS: %0.2f\n%d-gon\nPress <- or -> to change the number of the vertices", ebiten.CurrentTPS(), g.ngon)
|
||||
msg := fmt.Sprintf("TPS: %0.2f\n%d-gon\nPress <- or -> to change the number of the vertices", ebiten.ActualTPS(), g.ngon)
|
||||
ebitenutil.DebugPrint(screen, msg)
|
||||
}
|
||||
|
||||
|
@ -279,7 +279,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
}
|
||||
|
||||
ebitenutil.DebugPrintAt(screen, "WASD: move", 160, 0)
|
||||
ebitenutil.DebugPrintAt(screen, fmt.Sprintf("TPS: %0.2f", ebiten.CurrentTPS()), 51, 51)
|
||||
ebitenutil.DebugPrintAt(screen, fmt.Sprintf("TPS: %0.2f", ebiten.ActualTPS()), 51, 51)
|
||||
ebitenutil.DebugPrintAt(screen, fmt.Sprintf("Rays: 2*%d", len(rays)/2), padding, 222)
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ func (g *Game) Update() error {
|
||||
|
||||
func (g *Game) Draw(screen *ebiten.Image) {
|
||||
screen.DrawImage(g.offscreen, nil)
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f\nFPS: %0.2f", ebiten.CurrentTPS(), ebiten.CurrentFPS()))
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f\nFPS: %0.2f", ebiten.ActualTPS(), ebiten.ActualFPS()))
|
||||
}
|
||||
|
||||
func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
|
||||
|
@ -178,7 +178,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
v, i = rect(300-float32(cf), 50, 120, 120, color.RGBA{0x00, 0x80, 0x00, 0x80})
|
||||
screen.DrawTriangles(v, i, src, nil)
|
||||
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.CurrentTPS()))
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.ActualTPS()))
|
||||
}
|
||||
|
||||
func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
|
||||
|
@ -107,7 +107,7 @@ func (g *Game) Update() error {
|
||||
}
|
||||
|
||||
func (g *Game) Draw(screen *ebiten.Image) {
|
||||
msg := fmt.Sprintf("TPS: %0.2f\nThis is an example using infinite audio stream.", ebiten.CurrentTPS())
|
||||
msg := fmt.Sprintf("TPS: %0.2f\nThis is an example using infinite audio stream.", ebiten.ActualTPS())
|
||||
ebitenutil.DebugPrint(screen, msg)
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
if g.moveDirection == dirNone {
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("Press up/down/left/right to start"))
|
||||
} else {
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("FPS: %0.2f Level: %d Score: %d Best Score: %d", ebiten.CurrentFPS(), g.level, g.score, g.bestScore))
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("FPS: %0.2f Level: %d Score: %d Best Score: %d", ebiten.ActualFPS(), g.level, g.score, g.bestScore))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
msg := fmt.Sprintf(`TPS: %0.2f
|
||||
FPS: %0.2f
|
||||
Num of sprites: %d
|
||||
Press <- or -> to change the number of sprites`, ebiten.CurrentTPS(), ebiten.CurrentFPS(), g.sprites.num)
|
||||
Press <- or -> to change the number of sprites`, ebiten.ActualTPS(), ebiten.ActualFPS(), g.sprites.num)
|
||||
ebitenutil.DebugPrint(screen, msg)
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
FPS: %0.2f
|
||||
Num of sprites: %d
|
||||
Press <- or -> to change the number of sprites
|
||||
Press Q to quit`, ebiten.CurrentTPS(), ebiten.CurrentFPS(), g.sprites.num)
|
||||
Press Q to quit`, ebiten.ActualTPS(), ebiten.ActualFPS(), g.sprites.num)
|
||||
ebitenutil.DebugPrint(screen, msg)
|
||||
}
|
||||
|
||||
|
@ -326,7 +326,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
screen.DrawImage(g.canvas, nil)
|
||||
ebitenutil.DebugPrintAt(
|
||||
screen,
|
||||
fmt.Sprintf("TPS: %0.2f, FPS: %0.2f", ebiten.CurrentTPS(), ebiten.CurrentFPS()),
|
||||
fmt.Sprintf("TPS: %0.2f, FPS: %0.2f", ebiten.ActualTPS(), ebiten.ActualFPS()),
|
||||
1, 0,
|
||||
)
|
||||
ebitenutil.DebugPrintAt(
|
||||
@ -351,7 +351,7 @@ func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
ebiten.SetMaxTPS(250)
|
||||
ebiten.SetTPS(250)
|
||||
ebiten.SetWindowSize(width*scale, height*scale)
|
||||
ebiten.SetWindowTitle("Squirals (Ebiten Demo)")
|
||||
if err := ebiten.RunGame(NewGame()); err != nil {
|
||||
|
@ -82,7 +82,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
}
|
||||
}
|
||||
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.CurrentTPS()))
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.ActualTPS()))
|
||||
}
|
||||
|
||||
func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
|
||||
|
@ -253,7 +253,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
drawArc(screen, g.counter)
|
||||
drawWave(screen, g.counter)
|
||||
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f\nFPS: %0.2f", ebiten.CurrentTPS(), ebiten.CurrentFPS()))
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f\nFPS: %0.2f", ebiten.ActualTPS(), ebiten.ActualFPS()))
|
||||
}
|
||||
|
||||
func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
|
||||
|
@ -126,7 +126,7 @@ func (g *game) Update() error {
|
||||
runnableOnUnfocused := ebiten.IsRunnableOnUnfocused()
|
||||
cursorMode := ebiten.CursorMode()
|
||||
fpsMode := ebiten.FPSMode()
|
||||
tps := ebiten.MaxTPS()
|
||||
tps := ebiten.TPS()
|
||||
decorated := ebiten.IsWindowDecorated()
|
||||
positionX, positionY := ebiten.WindowPosition()
|
||||
g.transparent = ebiten.IsScreenTransparent()
|
||||
@ -257,7 +257,7 @@ func (g *game) Update() error {
|
||||
restore := false
|
||||
if ebiten.IsWindowMaximized() || ebiten.IsWindowMinimized() {
|
||||
if *flagAutoRestore {
|
||||
restore = g.count%ebiten.MaxTPS() == 0
|
||||
restore = g.count%ebiten.TPS() == 0
|
||||
} else {
|
||||
restore = inpututil.IsKeyJustPressed(ebiten.KeyE)
|
||||
}
|
||||
@ -277,7 +277,7 @@ func (g *game) Update() error {
|
||||
if fpsMode != ebiten.FPSMode() {
|
||||
ebiten.SetFPSMode(fpsMode)
|
||||
}
|
||||
ebiten.SetMaxTPS(tps)
|
||||
ebiten.SetTPS(tps)
|
||||
ebiten.SetWindowDecorated(decorated)
|
||||
if toUpdateWindowPosition {
|
||||
ebiten.SetWindowPosition(positionX, positionY)
|
||||
@ -318,7 +318,7 @@ func (g *game) Draw(screen *ebiten.Image) {
|
||||
minw, minh, maxw, maxh := ebiten.WindowSizeLimits()
|
||||
cx, cy := ebiten.CursorPosition()
|
||||
tpsStr := "Sync with FPS"
|
||||
if t := ebiten.MaxTPS(); t != ebiten.SyncWithFPS {
|
||||
if t := ebiten.TPS(); t != ebiten.SyncWithFPS {
|
||||
tpsStr = fmt.Sprintf("%d", t)
|
||||
}
|
||||
|
||||
@ -360,7 +360,7 @@ Window size limitation: (%d, %d) - (%d, %d)
|
||||
Cursor: (%d, %d)
|
||||
TPS: Current: %0.2f / Max: %s
|
||||
FPS: %0.2f
|
||||
Device Scale Factor: %0.2f`, msgM, msgR, fg, wx, wy, ww, wh, minw, minh, maxw, maxh, cx, cy, ebiten.CurrentTPS(), tpsStr, ebiten.CurrentFPS(), ebiten.DeviceScaleFactor())
|
||||
Device Scale Factor: %0.2f`, msgM, msgR, fg, wx, wy, ww, wh, minw, minh, maxw, maxh, cx, cy, ebiten.ActualTPS(), tpsStr, ebiten.ActualFPS(), ebiten.DeviceScaleFactor())
|
||||
ebitenutil.DebugPrint(screen, msg)
|
||||
}
|
||||
|
||||
|
2
internal/processtest/testdata/issue2154_2.go
vendored
2
internal/processtest/testdata/issue2154_2.go
vendored
@ -75,7 +75,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
|
||||
// The blow 3 line matters to reproduce #2154.
|
||||
mx, my := ebiten.CursorPosition()
|
||||
msg := fmt.Sprintf("TPS: %.01f; FPS: %.01f; cursor: (%d, %d)", ebiten.CurrentTPS(), ebiten.CurrentFPS(), mx, my)
|
||||
msg := fmt.Sprintf("TPS: %.01f; FPS: %.01f; cursor: (%d, %d)", ebiten.ActualTPS(), ebiten.ActualFPS(), mx, my)
|
||||
ebitenutil.DebugPrint(screen, msg)
|
||||
}
|
||||
|
||||
|
2
internal/processtest/testdata/issue2182.go
vendored
2
internal/processtest/testdata/issue2182.go
vendored
@ -76,7 +76,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
|
||||
// The blow 3 line matters to reproduce #2154.
|
||||
mx, my := ebiten.CursorPosition()
|
||||
msg := fmt.Sprintf("TPS: %.01f; FPS: %.01f; cursor: (%d, %d)", ebiten.CurrentTPS(), ebiten.CurrentFPS(), mx, my)
|
||||
msg := fmt.Sprintf("TPS: %.01f; FPS: %.01f; cursor: (%d, %d)", ebiten.ActualTPS(), ebiten.ActualFPS(), mx, my)
|
||||
ebitenutil.DebugPrint(screen, msg)
|
||||
}
|
||||
|
||||
|
67
run.go
67
run.go
@ -31,8 +31,8 @@ type Game interface {
|
||||
// that the time delta between two Updates is always 1 / TPS [s] (1/60[s] by default). As Ebitengine already
|
||||
// adjusts the number of Update calls, you don't have to measure time deltas in Update by e.g. OS timers.
|
||||
//
|
||||
// An actual TPS is available by CurrentTPS(), and the result might slightly differ from your expected TPS,
|
||||
// but still, your game logic should stick to the fixed time delta and should not rely on CurrentTPS() value.
|
||||
// An actual TPS is available by ActualTPS(), and the result might slightly differ from your expected TPS,
|
||||
// but still, your game logic should stick to the fixed time delta and should not rely on ActualTPS() value.
|
||||
// This API is for just measurement and/or debugging. In the long run, the number of Update calls should be
|
||||
// adjusted based on the set TPS on average.
|
||||
//
|
||||
@ -78,19 +78,27 @@ type Game interface {
|
||||
// DefaultTPS represents a default ticks per second, that represents how many times game updating happens in a second.
|
||||
const DefaultTPS = clock.DefaultTPS
|
||||
|
||||
// CurrentFPS returns the current number of FPS (frames per second), that represents
|
||||
// ActualFPS returns the current number of FPS (frames per second), that represents
|
||||
// how many swapping buffer happens per second.
|
||||
//
|
||||
// On some environments, CurrentFPS doesn't return a reliable value since vsync doesn't work well there.
|
||||
// If you want to measure the application's speed, Use CurrentTPS.
|
||||
// On some environments, ActualFPS doesn't return a reliable value since vsync doesn't work well there.
|
||||
// If you want to measure the application's speed, Use ActualTPS.
|
||||
//
|
||||
// This value is for measurement and/or debug, and your game logic should not rely on this value.
|
||||
//
|
||||
// CurrentFPS is concurrent-safe.
|
||||
func CurrentFPS() float64 {
|
||||
// ActualFPS is concurrent-safe.
|
||||
func ActualFPS() float64 {
|
||||
return clock.ActualFPS()
|
||||
}
|
||||
|
||||
// CurrentFPS returns the current number of FPS (frames per second), that represents
|
||||
// how many swapping buffer happens per second.
|
||||
//
|
||||
// Deprecated: as of v2.4. Use ActualFPS instead.
|
||||
func CurrentFPS() float64 {
|
||||
return ActualFPS()
|
||||
}
|
||||
|
||||
var (
|
||||
isRunGameEnded_ = int32(0)
|
||||
)
|
||||
@ -387,7 +395,7 @@ const (
|
||||
//
|
||||
// In FPSModeVsyncOffMinimum, the game's Update and Draw are called only when
|
||||
// 1) new inputting except for gamepads is detected, or 2) ScheduleFrame is called.
|
||||
// In FPSModeVsyncOffMinimum, TPS is SyncWithFPS no matter what TPS is specified at SetMaxTPS.
|
||||
// In FPSModeVsyncOffMinimum, TPS is SyncWithFPS no matter what TPS is specified at SetTPS.
|
||||
FPSModeVsyncOffMinimum FPSModeType = ui.FPSModeVsyncOffMinimum
|
||||
)
|
||||
|
||||
@ -413,21 +421,36 @@ func ScheduleFrame() {
|
||||
ui.Get().ScheduleFrame()
|
||||
}
|
||||
|
||||
// TPS returns the current maximum TPS.
|
||||
//
|
||||
// TPS is concurrent-safe.
|
||||
func TPS() int {
|
||||
return clock.TPS()
|
||||
}
|
||||
|
||||
// MaxTPS returns the current maximum TPS.
|
||||
//
|
||||
// MaxTPS is concurrent-safe.
|
||||
// Deprecated: as of v2.4. Use TPS instead.
|
||||
func MaxTPS() int {
|
||||
return clock.TPS()
|
||||
return TPS()
|
||||
}
|
||||
|
||||
// ActualTPS returns the current TPS (ticks per second),
|
||||
// that represents how many Update function is called in a second.
|
||||
//
|
||||
// This value is for measurement and/or debug, and your game logic should not rely on this value.
|
||||
//
|
||||
// ActualTPS is concurrent-safe.
|
||||
func ActualTPS() float64 {
|
||||
return clock.ActualTPS()
|
||||
}
|
||||
|
||||
// CurrentTPS returns the current TPS (ticks per second),
|
||||
// that represents how many Update function is called in a second.
|
||||
//
|
||||
// This value is for measurement and/or debug, and your game logic should not rely on this value.
|
||||
//
|
||||
// CurrentTPS is concurrent-safe.
|
||||
// Deprecated: as of v2.4. Use ActualTPS instead.
|
||||
func CurrentTPS() float64 {
|
||||
return clock.ActualTPS()
|
||||
return ActualTPS()
|
||||
}
|
||||
|
||||
// SyncWithFPS is a special TPS value that means TPS syncs with FPS.
|
||||
@ -438,18 +461,26 @@ const SyncWithFPS = clock.SyncWithFPS
|
||||
// Deprecated: as of v2.2. Use SyncWithFPS instead.
|
||||
const UncappedTPS = SyncWithFPS
|
||||
|
||||
// SetMaxTPS sets the maximum TPS (ticks per second),
|
||||
// SetTPS 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 SyncWithFPS, TPS is uncapped and the game is updated per frame.
|
||||
// If tps is negative but not SyncWithFPS, SetMaxTPS panics.
|
||||
// If tps is negative but not SyncWithFPS, SetTPS panics.
|
||||
//
|
||||
// SetMaxTPS is concurrent-safe.
|
||||
func SetMaxTPS(tps int) {
|
||||
// SetTPS is concurrent-safe.
|
||||
func SetTPS(tps int) {
|
||||
clock.SetTPS(tps)
|
||||
}
|
||||
|
||||
// SetMaxTPS sets the maximum TPS (ticks per second),
|
||||
// that represents how many updating function is called per second.
|
||||
//
|
||||
// Deprecated: as of v2.4. Use SetTPS instead.
|
||||
func SetMaxTPS(tps int) {
|
||||
SetTPS(tps)
|
||||
}
|
||||
|
||||
// IsScreenTransparent reports whether the window is transparent.
|
||||
//
|
||||
// IsScreenTransparent is concurrent-safe.
|
||||
|
Loading…
Reference in New Issue
Block a user