mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
examples: Use TPS instead of FPS to indicate how fast the app works
This commit is contained in:
parent
15260537a2
commit
2923bec0dc
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user