all: replace 60 with ebiten.TPS

This commit is contained in:
Hajime Hoshi 2025-02-08 17:20:52 +09:00
parent 947c87baae
commit 5b551bbf09
2 changed files with 2 additions and 2 deletions

View File

@ -92,7 +92,7 @@ func lerp(a, b, t float64) float64 {
func (g *Game) Update() error {
g.count++
r := float64(g.count) * ((1.0 / 60.0) * 2 * math.Pi) * 0.1 // full cycle every 10 seconds
r := float64(g.count) * ((1 / float64(ebiten.TPS())) * 2 * math.Pi) * 0.1 // full cycle every 10 seconds
g.xpos = (float64(screenWidth) / 2) + math.Cos(r)*(float64(screenWidth)/2)
g.panning = lerp(-1, 1, g.xpos/float64(screenWidth))

View File

@ -146,7 +146,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
op := &ebiten.DrawRectShaderOptions{}
op.Uniforms = map[string]any{
"Time": float32(g.time) / 60,
"Time": float32(g.time) / float32(ebiten.TPS()),
"Cursor": []float32{float32(cx), float32(cy)},
}
op.Images[0] = gopherImage