|
|
|
@ -10,6 +10,7 @@ import (
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"code.rocketnine.space/tslocum/boxbrawl/asset"
|
|
|
|
|
"code.rocketnine.space/tslocum/boxbrawl/component"
|
|
|
|
|
"code.rocketnine.space/tslocum/boxbrawl/entity"
|
|
|
|
|
"code.rocketnine.space/tslocum/boxbrawl/system"
|
|
|
|
@ -38,10 +39,17 @@ func NewGame() (*Game, error) {
|
|
|
|
|
g.reset()
|
|
|
|
|
|
|
|
|
|
if !addedGame {
|
|
|
|
|
// Set up entity component system.
|
|
|
|
|
entity.NewOnceEntity()
|
|
|
|
|
gohan.AddSystem(&system.MapSystem{})
|
|
|
|
|
gohan.AddSystem(&system.PlayerSystem{})
|
|
|
|
|
gohan.AddSystem(&system.UISystem{})
|
|
|
|
|
|
|
|
|
|
// Start playing music.
|
|
|
|
|
if !world.StartMuted {
|
|
|
|
|
asset.SoundMusic.Play()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addedGame = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -681,6 +689,15 @@ func (g *Game) Update() error {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Toggle music.
|
|
|
|
|
if inpututil.IsKeyJustPressed(ebiten.KeyM) && ebiten.IsKeyPressed(ebiten.KeyControl) {
|
|
|
|
|
if asset.SoundMusic.IsPlaying() {
|
|
|
|
|
asset.SoundMusic.Pause()
|
|
|
|
|
} else {
|
|
|
|
|
asset.SoundMusic.Play()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Change debug level.
|
|
|
|
|
if inpututil.IsKeyJustPressed(ebiten.KeyV) && ebiten.IsKeyPressed(ebiten.KeyControl) {
|
|
|
|
|
world.Debug++
|
|
|
|
@ -695,7 +712,7 @@ func (g *Game) Update() error {
|
|
|
|
|
if preset == world.TPS {
|
|
|
|
|
if i > 0 {
|
|
|
|
|
world.TPS = world.TPSPresets[i-1]
|
|
|
|
|
ebiten.SetTPS(world.TPS)
|
|
|
|
|
ebiten.SetMaxTPS(world.TPS)
|
|
|
|
|
log.Printf("Set TPS to %d", world.TPS)
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
@ -709,7 +726,7 @@ func (g *Game) Update() error {
|
|
|
|
|
if preset == world.TPS {
|
|
|
|
|
if i < len(world.TPSPresets)-1 {
|
|
|
|
|
world.TPS = world.TPSPresets[i+1]
|
|
|
|
|
ebiten.SetTPS(world.TPS)
|
|
|
|
|
ebiten.SetMaxTPS(world.TPS)
|
|
|
|
|
log.Printf("Set TPS to %d", world.TPS)
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|