From d1e69dca41dda8610c57ae763dc981b5421ae513 Mon Sep 17 00:00:00 2001 From: davidovski Date: Tue, 23 Apr 2024 00:11:11 +0100 Subject: pan upwards --- main.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/main.go b/main.go index aba19e8..1be1bef 100644 --- a/main.go +++ b/main.go @@ -436,10 +436,10 @@ func (g *Game) IsShowTheEnd() bool { func (g *Game) Draw(screen *ebiten.Image) { - g.surface.Fill(color.Alpha16{0x9ccf}) - DrawBackground(g.surface, g.time) + DrawBackground(screen, g.time) - g.tilemap.Draw(g.surface, float32(g.offsetX), float32(g.offsetY-2)) + g.surface.Fill(color.RGBA{0, 0, 0, 0}) + g.tilemap.Draw(g.surface, 0, -2) for i := len(g.objects)-1; i >= 0; i-- { obj := g.objects[i] @@ -453,25 +453,25 @@ func (g *Game) Draw(screen *ebiten.Image) { } op := &ebiten.DrawImageOptions{} + op.GeoM.Translate(float64(g.offsetX), float64(g.offsetY-2)) if g.IsShowTheEnd() { // draw THE END - a := float32(endCardDuration - (g.time - g.animStart)) / float32(endCardDuration); - a = float32(math.Pow(float64(a), 10)) + a := float64(endCardDuration - (g.time - g.animStart)) / float64(endCardDuration); + a = 1 - float64(math.Pow(float64(a), 10)) if g.state == PAUSED { - a = 0.0 + a = 10.0 } - if a > 1.0 { - a = 1.0 + if a < 0.0 { + a = 0.0 } - fmt.Printf("alpha: %.4f\n", a) + op.GeoM.Translate(float64(g.offsetX), float64(g.offsetY) + a*screenHeight/2) - op.ColorScale.Scale(a, a, a, 1); screen.DrawImage(g.surface, op) - g.DrawTheEnd(screen, 1-a) + g.DrawTheEnd(screen, float32(a)) // AFTER THE END if g.state == END && g.time - g.animStart > endCardDuration { -- cgit v1.2.1