mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
examples/airship: Introduce repeatedGophersImage
This commit is contained in:
parent
dc159cb37c
commit
aa96822ce5
@ -41,6 +41,7 @@ var (
|
|||||||
angle: maxAngle * 3 / 4,
|
angle: maxAngle * 3 / 4,
|
||||||
}
|
}
|
||||||
gophersImage *ebiten.Image
|
gophersImage *ebiten.Image
|
||||||
|
repeatedGophersImage *ebiten.Image
|
||||||
groundImage *ebiten.Image
|
groundImage *ebiten.Image
|
||||||
fogImage *ebiten.Image
|
fogImage *ebiten.Image
|
||||||
)
|
)
|
||||||
@ -124,18 +125,14 @@ func updateGroundImage(ground *ebiten.Image) error {
|
|||||||
a := thePlayer.Angle()
|
a := thePlayer.Angle()
|
||||||
gw, gh := ground.Size()
|
gw, gh := ground.Size()
|
||||||
w, h := gophersImage.Size()
|
w, h := gophersImage.Size()
|
||||||
for j := -2; j <= 2; j++ {
|
|
||||||
for i := -2; i <= 2; i++ {
|
|
||||||
op := &ebiten.DrawImageOptions{}
|
op := &ebiten.DrawImageOptions{}
|
||||||
op.GeoM.Translate(float64(-x16)/16, float64(-y16)/16)
|
op.GeoM.Translate(float64(-x16)/16, float64(-y16)/16)
|
||||||
op.GeoM.Translate(float64(w*i), float64(h*j))
|
op.GeoM.Translate(float64(-w*2), float64(-h*2))
|
||||||
op.GeoM.Rotate(float64(-a)*2*math.Pi/maxAngle + math.Pi*3.0/2.0)
|
op.GeoM.Rotate(float64(-a)*2*math.Pi/maxAngle + math.Pi*3.0/2.0)
|
||||||
op.GeoM.Translate(float64(gw)/2, float64(gh)-32)
|
op.GeoM.Translate(float64(gw)/2, float64(gh)-32)
|
||||||
if err := ground.DrawImage(gophersImage, op); err != nil {
|
if err := ground.DrawImage(repeatedGophersImage, op); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,6 +227,21 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
w, h := gophersImage.Size()
|
||||||
|
const repeat = 5
|
||||||
|
repeatedGophersImage, err = ebiten.NewImage(w*repeat, h*repeat, ebiten.FilterNearest)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
for j := 0; j < repeat; j++ {
|
||||||
|
for i := 0; i < repeat; i++ {
|
||||||
|
op := &ebiten.DrawImageOptions{}
|
||||||
|
op.GeoM.Translate(float64(w*i), float64(h*j))
|
||||||
|
if err := repeatedGophersImage.DrawImage(gophersImage, op); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
groundWidth := screenWidth + 70
|
groundWidth := screenWidth + 70
|
||||||
groundImage, err = ebiten.NewImage(groundWidth, screenHeight*2/3+50, ebiten.FilterNearest)
|
groundImage, err = ebiten.NewImage(groundWidth, screenHeight*2/3+50, ebiten.FilterNearest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user