diff --git a/README.md b/README.md index 66129f7..b47a52d 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,9 @@ Once it's complete enough I'd like to add a scrolling mode. I'm curious what the Controls are left, right and space to flap. + https://depsypher.github.io/gojoust/ + + * Press `S` key to toggle sound + * Press `P` key to toggle pause + * Press `G` key to toggle god/debug mode diff --git a/assets/audio/embed.go b/assets/audio/embed.go index a42e757..45b4b6f 100644 --- a/assets/audio/embed.go +++ b/assets/audio/embed.go @@ -16,8 +16,8 @@ const ( FlapDnSound Sound = 3 FlapUpSound Sound = 4 HitSound Sound = 5 - JoustFreSound Sound = 6 - JoustLavSound Sound = 7 + OneUpSound Sound = 6 + LavaSound Sound = 7 PteroSound Sound = 8 SkidSound Sound = 9 SpawnSound Sound = 10 @@ -47,10 +47,10 @@ var ( Hit []byte //go:embed joustfre.ogg - JoustFre []byte + OneUp []byte //go:embed joustlav.ogg - JoustLav []byte + Lava []byte //go:embed ptero.ogg Ptero []byte @@ -74,14 +74,21 @@ var ( Whomp []byte soundFiles = map[Sound][]byte{ - BumpSound: Bump, - EggSound: Egg, - EnergizeSound: Energize, - FlapDnSound: FlapDn, - FlapUpSound: FlapUp, - Walk1Sound: Walk1, - Walk2Sound: Walk2, - HitSound: Hit, + BumpSound: Bump, + EggSound: Egg, + EnergizeSound: Energize, + FlapDnSound: FlapDn, + FlapUpSound: FlapUp, + OneUpSound: OneUp, + LavaSound: Lava, + PteroSound: Ptero, + SkidSound: Skid, + SpawnSound: Spawn, + SpawnEnemySound: SpawnEnemy, + Walk1Sound: Walk1, + Walk2Sound: Walk2, + HitSound: Hit, + WhompSound: Whomp, } audioContext = audio.NewContext(44100) ) diff --git a/entity/player.go b/entity/player.go index b82bb63..548bfc6 100644 --- a/entity/player.go +++ b/entity/player.go @@ -133,8 +133,14 @@ func buzzardCollision(gs *GameState, p *Player) { p.Vy = -0.5 p.Y = enemy.Y - float64(enemy.Height)*0.6 enemy.state = UNMOUNTED + if err := gs.Sounds[audio.HitSound].Play(gs.SoundOn); err != nil { + log.Fatal("Error playing sound", err) + } } else if py > by { p.state = UNMOUNTED + if err := gs.Sounds[audio.HitSound].Play(gs.SoundOn); err != nil { + log.Fatal("Error playing sound", err) + } } else { p.bounce(gs, enemy.Sprite) enemy.bounce(gs, p.Sprite) diff --git a/main.go b/main.go index 7f6b737..a2fb35f 100644 --- a/main.go +++ b/main.go @@ -40,6 +40,7 @@ func (g *Game) init() { g.state = &entity.GameState{ Keys: make(map[app.Control]bool), GodMode: false, + SoundOn: true, WaveStart: time.Now(), }