mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
examples/airship: better approximate scaling
This commit is contained in:
parent
b526aed817
commit
2ec4e31d60
@ -173,7 +173,7 @@ func updateGroundImage(ground *ebiten.Image) {
|
|||||||
|
|
||||||
func scaleForLine(x int) float64 {
|
func scaleForLine(x int) float64 {
|
||||||
// This is an very rough approximate calculation.
|
// This is an very rough approximate calculation.
|
||||||
return math.Pow(float64(x), 1.2)
|
return math.Pow(float64(x)/2.5, 1.2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func drawGroundImage(screen *ebiten.Image, ground *ebiten.Image) {
|
func drawGroundImage(screen *ebiten.Image, ground *ebiten.Image) {
|
||||||
@ -188,7 +188,7 @@ func drawGroundImage(screen *ebiten.Image, ground *ebiten.Image) {
|
|||||||
op.GeoM.Reset()
|
op.GeoM.Reset()
|
||||||
x := scaleForLine(i)
|
x := scaleForLine(i)
|
||||||
j := scaleForLine(i)
|
j := scaleForLine(i)
|
||||||
dx0, dy0, dx1, dy1 := -x, j, float64(w)+x, j+4
|
dx0, dy0, dx1, dy1 := -x, j, float64(w)+x, j+6
|
||||||
sw := float64(dx1-dx0) / float64(w)
|
sw := float64(dx1-dx0) / float64(w)
|
||||||
sh := float64(dy1 - dy0)
|
sh := float64(dy1 - dy0)
|
||||||
op.GeoM.Scale(sw, sh)
|
op.GeoM.Scale(sw, sh)
|
||||||
|
Loading…
Reference in New Issue
Block a user