mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-11 10:33:16 +01:00
all: replace 60 with ebiten.TPS
This commit is contained in:
parent
947c87baae
commit
5b551bbf09
@ -92,7 +92,7 @@ func lerp(a, b, t float64) float64 {
|
|||||||
|
|
||||||
func (g *Game) Update() error {
|
func (g *Game) Update() error {
|
||||||
g.count++
|
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.xpos = (float64(screenWidth) / 2) + math.Cos(r)*(float64(screenWidth)/2)
|
||||||
g.panning = lerp(-1, 1, g.xpos/float64(screenWidth))
|
g.panning = lerp(-1, 1, g.xpos/float64(screenWidth))
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
|||||||
|
|
||||||
op := &ebiten.DrawRectShaderOptions{}
|
op := &ebiten.DrawRectShaderOptions{}
|
||||||
op.Uniforms = map[string]any{
|
op.Uniforms = map[string]any{
|
||||||
"Time": float32(g.time) / 60,
|
"Time": float32(g.time) / float32(ebiten.TPS()),
|
||||||
"Cursor": []float32{float32(cx), float32(cy)},
|
"Cursor": []float32{float32(cx), float32(cy)},
|
||||||
}
|
}
|
||||||
op.Images[0] = gopherImage
|
op.Images[0] = gopherImage
|
||||||
|
Loading…
Reference in New Issue
Block a user