Browse Source

FEATURE: Added scaled background

master
parent
commit
c6a7ae3926
  1. 12
      src/main.go
  2. BIN
      src/resources/background_1.png
  3. BIN
      src/resources/background_2.png

12
src/main.go

@ -71,6 +71,8 @@ func NewGame() *Game {
"capybara1": ebiten.NewImageFromImage(ImageFromFile("capybara_1.png")),
"capybara2": ebiten.NewImageFromImage(ImageFromFile("capybara_2.png")),
"capybara3": ebiten.NewImageFromImage(ImageFromFile("capybara_3.png")),
"background1": ebiten.NewImageFromImage(ImageFromFile("background_1.png")),
"background2": ebiten.NewImageFromImage(ImageFromFile("background_2.png")),
},
Font: util.NewFont(fnt, &opentype.FaceOptions{
Size: 24,
@ -190,6 +192,14 @@ func (g *Game) Draw(screen *ebiten.Image) {
// Background
screen.Fill(color.Black)
backBounds := g.ImageResources["background1"].Bounds()
op := &ebiten.DrawImageOptions{}
op.GeoM.Scale(
float64(screen.Bounds().Dx())/float64(backBounds.Dx()),
float64(screen.Bounds().Dy())/float64(backBounds.Dy()),
)
screen.DrawImage(g.ImageResources["background1"], op)
// Capybara
var capybaraKey string
switch g.Save.Level {
@ -204,7 +214,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
}
scale := 10.0
op := &ebiten.DrawImageOptions{}
op = &ebiten.DrawImageOptions{}
if g.AnimationData.BounceDirectionFlag {
g.AnimationData.Theta += 0.001
} else {

BIN
src/resources/background_1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
src/resources/background_2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Loading…
Cancel
Save