|
|
@ -42,14 +42,15 @@ type AnimationData struct { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type Game struct { |
|
|
|
type Game struct { |
|
|
|
WorkingDir string |
|
|
|
WorkingDir string |
|
|
|
Config conf.Configuration |
|
|
|
Config conf.Configuration |
|
|
|
Save save.Save |
|
|
|
Save save.Save |
|
|
|
AudioContext *audio.Context |
|
|
|
AudioContext *audio.Context |
|
|
|
AudioPlayers map[string]*audio.Player |
|
|
|
AudioPlayers map[string]*audio.Player |
|
|
|
ImageResources map[string]*ebiten.Image |
|
|
|
ImageResources map[string]*ebiten.Image |
|
|
|
Font font.Face |
|
|
|
Font font.Face |
|
|
|
AnimationData AnimationData |
|
|
|
AnimationData AnimationData |
|
|
|
|
|
|
|
PassiveIncomeTicker int |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func NewGame() *Game { |
|
|
|
func NewGame() *Game { |
|
|
@ -84,6 +85,7 @@ func NewGame() *Game { |
|
|
|
BounceDirectionFlag: true, |
|
|
|
BounceDirectionFlag: true, |
|
|
|
Squish: 0, |
|
|
|
Squish: 0, |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
PassiveIncomeTicker: 0, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -163,15 +165,16 @@ func (g *Game) Update() error { |
|
|
|
g.Save.TimesClicked++ |
|
|
|
g.Save.TimesClicked++ |
|
|
|
g.Save.Points++ |
|
|
|
g.Save.Points++ |
|
|
|
g.AnimationData.Squish += 0.5 |
|
|
|
g.AnimationData.Squish += 0.5 |
|
|
|
go g.PlaySound("boop") |
|
|
|
g.PlaySound("boop") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonLeft) && |
|
|
|
if g.Save.Points > 0 && g.Save.Points%100 == 0 { |
|
|
|
g.Save.Points > 0 && |
|
|
|
|
|
|
|
g.Save.Points%100 == 0 { |
|
|
|
|
|
|
|
// Level progression
|
|
|
|
// Level progression
|
|
|
|
g.Save.Level++ |
|
|
|
g.Save.Level++ |
|
|
|
go g.PlaySound("levelup") |
|
|
|
g.Save.PassiveIncome++ |
|
|
|
|
|
|
|
// Bump points number immediately in order to not mistakengly level up on the next update
|
|
|
|
|
|
|
|
g.Save.Points++ |
|
|
|
|
|
|
|
g.PlaySound("levelup") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Capybara Animation
|
|
|
|
// Capybara Animation
|
|
|
@ -185,6 +188,14 @@ func (g *Game) Update() error { |
|
|
|
g.AnimationData.Squish -= 0.05 |
|
|
|
g.AnimationData.Squish -= 0.05 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Passive points income
|
|
|
|
|
|
|
|
if g.PassiveIncomeTicker == ebiten.TPS() { |
|
|
|
|
|
|
|
g.PassiveIncomeTicker = 0 |
|
|
|
|
|
|
|
g.Save.Points += g.Save.PassiveIncome |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
g.PassiveIncomeTicker++ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -250,7 +261,7 @@ func (g *Game) Draw(screen *ebiten.Image) { |
|
|
|
screen, |
|
|
|
screen, |
|
|
|
msg, |
|
|
|
msg, |
|
|
|
g.Font, |
|
|
|
g.Font, |
|
|
|
screen.Bounds().Dx()-len(msg)*24, |
|
|
|
screen.Bounds().Dx()-len(msg)*19, |
|
|
|
30, |
|
|
|
30, |
|
|
|
color.White, |
|
|
|
color.White, |
|
|
|
) |
|
|
|
) |
|
|
@ -262,7 +273,8 @@ func (g *Game) Draw(screen *ebiten.Image) { |
|
|
|
msg, |
|
|
|
msg, |
|
|
|
g.Font, |
|
|
|
g.Font, |
|
|
|
10, |
|
|
|
10, |
|
|
|
screen.Bounds().Dy()-30, |
|
|
|
// screen.Bounds().Dy()-30,
|
|
|
|
|
|
|
|
screen.Bounds().Dy()-24*2, |
|
|
|
color.White, |
|
|
|
color.White, |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
@ -272,8 +284,9 @@ func (g *Game) Draw(screen *ebiten.Image) { |
|
|
|
screen, |
|
|
|
screen, |
|
|
|
msg, |
|
|
|
msg, |
|
|
|
g.Font, |
|
|
|
g.Font, |
|
|
|
screen.Bounds().Dx()-len(msg)*19, |
|
|
|
// screen.Bounds().Dx()-len(msg)*17,
|
|
|
|
screen.Bounds().Dy()-30, |
|
|
|
10, |
|
|
|
|
|
|
|
screen.Bounds().Dy()-24, |
|
|
|
color.White, |
|
|
|
color.White, |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
@ -342,7 +355,7 @@ func main() { |
|
|
|
ebiten.SetWindowClosingHandled(true) // So we can save data
|
|
|
|
ebiten.SetWindowClosingHandled(true) // So we can save data
|
|
|
|
ebiten.SetRunnableOnUnfocused(true) |
|
|
|
ebiten.SetRunnableOnUnfocused(true) |
|
|
|
ebiten.SetWindowResizingMode(ebiten.WindowResizingModeEnabled) |
|
|
|
ebiten.SetWindowResizingMode(ebiten.WindowResizingModeEnabled) |
|
|
|
ebiten.SetWindowSizeLimits(480, 320, -1, -1) |
|
|
|
ebiten.SetWindowSizeLimits(380, 576, -1, -1) |
|
|
|
ebiten.SetTPS(60) |
|
|
|
ebiten.SetTPS(60) |
|
|
|
ebiten.SetWindowSize(game.Config.WindowSize[0], game.Config.WindowSize[1]) |
|
|
|
ebiten.SetWindowSize(game.Config.WindowSize[0], game.Config.WindowSize[1]) |
|
|
|
ebiten.SetWindowPosition(game.Config.LastWindowPosition[0], game.Config.LastWindowPosition[1]) |
|
|
|
ebiten.SetWindowPosition(game.Config.LastWindowPosition[0], game.Config.LastWindowPosition[1]) |
|
|
|