Browse Source

FEATURE: Capybara dimensions are now scaled to screen dimensions

master
parent
commit
4496a5ad84
  1. 22
      src/main.go
  2. BIN
      src/resources/capybara_2.png
  3. BIN
      src/resources/capybara_3.png
  4. 2
      src/save/save.go

22
src/main.go

@ -187,7 +187,8 @@ func (g *Game) Update() error {
g.PlaySound("boop") g.PlaySound("boop")
} }
if g.Save.Points > 0 && g.Save.Points%100 == 0 { /////////// TODO
if g.Save.Points > 0 && g.Save.Points%100 < uint64(g.Save.Level) {
// Level progression // Level progression
g.Save.Level++ g.Save.Level++
g.Save.PassiveIncome++ g.Save.PassiveIncome++
@ -243,7 +244,6 @@ func (g *Game) Draw(screen *ebiten.Image) {
capybaraKey = "capybara3" capybaraKey = "capybara3"
} }
scale := 10.0
op = &ebiten.DrawImageOptions{} op = &ebiten.DrawImageOptions{}
if g.AnimationData.BounceDirectionFlag { if g.AnimationData.BounceDirectionFlag {
g.AnimationData.Theta += 0.001 g.AnimationData.Theta += 0.001
@ -251,16 +251,22 @@ func (g *Game) Draw(screen *ebiten.Image) {
g.AnimationData.Theta -= 0.001 g.AnimationData.Theta -= 0.001
} }
op.GeoM.Scale(scale+g.AnimationData.Squish, scale-g.AnimationData.Squish) capybaraBounds := g.ImageResources[capybaraKey].Bounds()
scaleX := float64(screen.Bounds().Dx()) / float64(capybaraBounds.Dx()) / 2.5
scaleY := float64(screen.Bounds().Dy()) / float64(capybaraBounds.Dy()) / 2.5
op.GeoM.Scale(
scaleX+g.AnimationData.Squish,
scaleY-g.AnimationData.Squish,
)
op.GeoM.Rotate(g.AnimationData.Theta) op.GeoM.Rotate(g.AnimationData.Theta)
width := g.ImageResources[capybaraKey].Bounds().Dx() * int(scale) capyWidth := float64(g.ImageResources[capybaraKey].Bounds().Dx()) * scaleX
height := g.ImageResources[capybaraKey].Bounds().Dy() * int(scale) capyHeight := float64(g.ImageResources[capybaraKey].Bounds().Dy()) * scaleY
op.GeoM.Translate( op.GeoM.Translate(
float64(screen.Bounds().Dx()/2)-float64(width/2), float64(screen.Bounds().Dx()/2)-capyWidth/2,
float64(screen.Bounds().Dy()/2)-float64(height/2), float64(screen.Bounds().Dy()/2)-capyHeight/2,
) )
screen.DrawImage(g.ImageResources[capybaraKey], op) screen.DrawImage(g.ImageResources[capybaraKey], op)
// Points // Points

BIN
src/resources/capybara_2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 508 B

After

Width:  |  Height:  |  Size: 457 B

BIN
src/resources/capybara_3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 457 B

After

Width:  |  Height:  |  Size: 508 B

2
src/save/save.go

@ -30,7 +30,7 @@ const CurrentVersion uint8 = 1
type Save struct { type Save struct {
SaveVersion uint8 `json:"saveVersion"` SaveVersion uint8 `json:"saveVersion"`
Points uint64 `json:"points"` Points uint64 `json:"points"`
Level uint8 `json:"level"` Level uint32 `json:"level"`
CreatedUnix uint64 `json:"createdUnix"` CreatedUnix uint64 `json:"createdUnix"`
LastOpenedUnix uint64 `json:"lastOpenedUnix"` LastOpenedUnix uint64 `json:"lastOpenedUnix"`
TimesClicked uint64 `json:"timesClicked"` TimesClicked uint64 `json:"timesClicked"`

Loading…
Cancel
Save