examples: Use TPS instead of FPS to indicate how fast the app works

This commit is contained in:
Hajime Hoshi 2018-09-30 02:27:33 +09:00
parent 15260537a2
commit 2923bec0dc
16 changed files with 22 additions and 22 deletions

View File

@ -261,7 +261,7 @@ func update(screen *ebiten.Image) error {
// Draw the message.
tutrial := "Space: Move forward\nLeft/Right: Rotate"
msg := fmt.Sprintf("FPS: %0.2f\n%s", ebiten.CurrentFPS(), tutrial)
msg := fmt.Sprintf("TPS: %0.2f\n%s", ebiten.CurrentTPS(), tutrial)
ebitenutil.DebugPrint(screen, msg)
return nil
}

View File

@ -207,12 +207,12 @@ func (p *Player) draw(screen *ebiten.Image) {
currentTimeStr := fmt.Sprintf("%02d:%02d", m, s)
// Draw the debug message.
msg := fmt.Sprintf(`FPS: %0.2f
msg := fmt.Sprintf(`TPS: %0.2f
Press S to toggle Play/Pause
Press P to play SE
Press Z or X to change volume of the music
Press B to switch the run-in-background state
Current Time: %s`, ebiten.CurrentFPS(), currentTimeStr)
Current Time: %s`, ebiten.CurrentTPS(), currentTimeStr)
ebitenutil.DebugPrint(screen, msg)
}

View File

@ -79,11 +79,11 @@ func update(screen *ebiten.Image) error {
if pos > 5*time.Second {
pos = (player.Current()-5*time.Second)%(4*time.Second) + 5*time.Second
}
msg := fmt.Sprintf(`FPS: %0.2f
msg := fmt.Sprintf(`TPS: %0.2f
This is an example using audio.NewInfiniteLoop.
Intro: 0[s] - %[2]d[s]
Loop: %[2]d[s] - %[3]d[s]
Current: %0.2[4]f[s]`, ebiten.CurrentFPS(), introLengthInSecond, introLengthInSecond+loopLengthInSecond, float64(pos)/float64(time.Second))
Current: %0.2[4]f[s]`, ebiten.CurrentTPS(), introLengthInSecond, introLengthInSecond+loopLengthInSecond, float64(pos)/float64(time.Second))
ebitenutil.DebugPrint(screen, msg)
return nil
}

View File

@ -55,7 +55,7 @@ func update(screen *ebiten.Image) error {
screen.DrawImage(dot, op)
})
ebitenutil.DebugPrint(screen, fmt.Sprint(ebiten.CurrentFPS()))
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.CurrentTPS()))
return nil
}

View File

@ -266,7 +266,7 @@ func (g *Game) Update(screen *ebiten.Image) error {
scoreStr := fmt.Sprintf("%04d", g.score())
text.Draw(screen, scoreStr, arcadeFont, screenWidth-len(scoreStr)*fontSize, fontSize, color.White)
ebitenutil.DebugPrint(screen, fmt.Sprintf("FPS: %0.2f", ebiten.CurrentFPS()))
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.CurrentTPS()))
return nil
}

View File

@ -140,7 +140,7 @@ func update(screen *ebiten.Image) error {
const x = 20
// Draw info
msg := fmt.Sprintf("FPS: %0.2f", ebiten.CurrentFPS())
msg := fmt.Sprintf("TPS: %0.2f", ebiten.CurrentTPS())
text.Draw(screen, msg, mplusNormalFont, x, 40, color.White)
// Draw the sample text

View File

@ -100,7 +100,7 @@ func update(screen *ebiten.Image) error {
}
}
ebitenutil.DebugPrint(screen, fmt.Sprintf("FPS: %0.2f", ebiten.CurrentFPS()))
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.CurrentTPS()))
return nil
}

View File

@ -65,7 +65,7 @@ func update(screen *ebiten.Image) error {
}
screen.ReplacePixels(noiseImage.Pix)
ebitenutil.DebugPrint(screen, fmt.Sprintf("FPS: %f", ebiten.CurrentFPS()))
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.CurrentTPS()))
return nil
}

View File

@ -228,7 +228,7 @@ func update(screen *ebiten.Image) error {
screen.Fill(color.RGBA{0x80, 0x80, 0xc0, 0xff})
screen.DrawImage(pianoImage, nil)
ebitenutil.DebugPrint(screen, fmt.Sprintf("FPS: %0.2f", ebiten.CurrentFPS()))
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.CurrentTPS()))
return nil
}

View File

@ -104,8 +104,8 @@ func update(screen *ebiten.Image) error {
op.GeoM.Translate(float64(charX), float64(charY))
screen.DrawImage(loadedSprite, op)
// FPS counter
fps := fmt.Sprintf("FPS: %f", ebiten.CurrentFPS())
// TPS counter
fps := fmt.Sprintf("TPS: %f", ebiten.CurrentTPS())
ebitenutil.DebugPrint(screen, fps)
return nil

View File

@ -173,7 +173,7 @@ func update(screen *ebiten.Image) error {
v, i = rect(300-float32(cf), 50, 120, 120, color.RGBA{0x00, 0x80, 0x00, 0x80})
screen.DrawTriangles(v, i, emptyImage, nil)
ebitenutil.DebugPrint(screen, fmt.Sprintf("FPS: %0.2f", ebiten.CurrentFPS()))
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.CurrentTPS()))
return nil
}

View File

@ -93,7 +93,7 @@ func update(screen *ebiten.Image) error {
if ebiten.IsDrawingSkipped() {
return nil
}
msg := fmt.Sprintf("FPS: %0.2f\nThis is an example using infinite audio stream.", ebiten.CurrentFPS())
msg := fmt.Sprintf("TPS: %0.2f\nThis is an example using infinite audio stream.", ebiten.CurrentTPS())
ebitenutil.DebugPrint(screen, msg)
return nil
}

View File

@ -173,9 +173,9 @@ func update(screen *ebiten.Image) error {
op.GeoM.Translate(float64(s.x), float64(s.y))
screen.DrawImage(ebitenImage, op)
}
msg := fmt.Sprintf(`FPS: %0.2f
msg := fmt.Sprintf(`TPS: %0.2f
Num of sprites: %d
Press <- or -> to change the number of sprites`, ebiten.CurrentFPS(), sprites.num)
Press <- or -> to change the number of sprites`, ebiten.CurrentTPS(), sprites.num)
ebitenutil.DebugPrint(screen, msg)
return nil
}

View File

@ -179,10 +179,10 @@ func update(screen *ebiten.Image) error {
op.GeoM.Translate(float64(s.x), float64(s.y))
screen.DrawImage(ebitenImage, op)
}
msg := fmt.Sprintf(`FPS: %0.2f
msg := fmt.Sprintf(`TPS: %0.2f
Num of sprites: %d
Press <- or -> to change the number of sprites
Press Q to quit`, ebiten.CurrentFPS(), sprites.num)
Press Q to quit`, ebiten.CurrentTPS(), sprites.num)
ebitenutil.DebugPrint(screen, msg)
return nil
}

View File

@ -125,7 +125,7 @@ func update(screen *ebiten.Image) error {
}
}
ebitenutil.DebugPrint(screen, fmt.Sprintf("FPS: %0.2f", ebiten.CurrentFPS()))
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.CurrentTPS()))
return nil
}

View File

@ -189,8 +189,8 @@ Press V key to switch vsync
Press T key to switch TPS (ticks per second)
Press Q key to quit
Cursor: (%d, %d)
FPS: %0.2f
TPS: Current: %0.2f / Max: %s`, x, y, ebiten.CurrentFPS(), ebiten.CurrentTPS(), tpsStr)
TPS: Current: %0.2f / Max: %s
FPS: %0.2f`, x, y, ebiten.CurrentTPS(), tpsStr, ebiten.CurrentFPS())
ebitenutil.DebugPrint(screen, msg)
return nil
}