mirror of
https://github.com/BigJk/end_of_eden.git
synced 2026-02-06 10:48:09 +00:00
Added 2 music tracks.
This commit is contained in:
parent
3fffbedc20
commit
fac559ccce
BIN
assets/audio/music/energetic_orthogonal_expansions.mp3
Normal file
BIN
assets/audio/music/energetic_orthogonal_expansions.mp3
Normal file
Binary file not shown.
BIN
assets/audio/music/planet_mining.mp3
Normal file
BIN
assets/audio/music/planet_mining.mp3
Normal file
Binary file not shown.
Binary file not shown.
@ -50,6 +50,8 @@ As you struggle to gather your bearings, you notice a blinking panel on the wall
|
||||
}
|
||||
},
|
||||
on_enter = function()
|
||||
play_music("energetic_orthogonal_expansions")
|
||||
|
||||
-- Give the player it's start cards
|
||||
give_card("MELEE_HIT", PLAYER_ID)
|
||||
give_card("MELEE_HIT", PLAYER_ID)
|
||||
|
||||
@ -1,23 +1,25 @@
|
||||
package audio
|
||||
|
||||
import (
|
||||
"github.com/faiface/beep/mp3"
|
||||
"github.com/faiface/beep/wav"
|
||||
"io/fs"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/faiface/beep"
|
||||
"github.com/faiface/beep/effects"
|
||||
"github.com/faiface/beep/mp3"
|
||||
"github.com/faiface/beep/speaker"
|
||||
"github.com/faiface/beep/wav"
|
||||
)
|
||||
|
||||
const sampleRate = 44100
|
||||
const baseVolume = -1
|
||||
|
||||
var mtx = sync.Mutex{}
|
||||
var sounds = map[string]*beep.Buffer{}
|
||||
var enabled = false
|
||||
var music = &beep.Ctrl{
|
||||
@ -32,47 +34,66 @@ func InitAudio() {
|
||||
return
|
||||
}
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
|
||||
_ = filepath.Walk("./assets/audio", func(path string, info fs.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var streamer beep.StreamSeekCloser
|
||||
var format beep.Format
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
if !info.IsDir() {
|
||||
if strings.HasSuffix(path, ".mp3") {
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var streamer beep.StreamSeekCloser
|
||||
var format beep.Format
|
||||
|
||||
streamer, format, err = mp3.Decode(f)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else if strings.HasSuffix(path, ".wav") {
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !info.IsDir() {
|
||||
if strings.HasSuffix(path, ".mp3") {
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
log.Println("Audio error:", err)
|
||||
return
|
||||
}
|
||||
|
||||
streamer, format, err = wav.Decode(f)
|
||||
if err != nil {
|
||||
return err
|
||||
streamer, format, err = mp3.Decode(f)
|
||||
if err != nil {
|
||||
log.Println("Audio error:", err)
|
||||
return
|
||||
}
|
||||
} else if strings.HasSuffix(path, ".wav") {
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
log.Println("Audio error:", err)
|
||||
return
|
||||
}
|
||||
|
||||
streamer, format, err = wav.Decode(f)
|
||||
if err != nil {
|
||||
log.Println("Audio error:", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if streamer != nil {
|
||||
buf := beep.NewBuffer(beep.Format{
|
||||
SampleRate: sampleRate,
|
||||
NumChannels: 2,
|
||||
Precision: 2,
|
||||
})
|
||||
buf.Append(beep.Resample(6, format.SampleRate, sampleRate, streamer))
|
||||
sounds[strings.Split(filepath.Base(path), ".")[0]] = buf
|
||||
}
|
||||
if streamer != nil {
|
||||
buf := beep.NewBuffer(beep.Format{
|
||||
SampleRate: sampleRate,
|
||||
NumChannels: 2,
|
||||
Precision: 2,
|
||||
})
|
||||
|
||||
if format.SampleRate == sampleRate {
|
||||
buf.Append(streamer)
|
||||
} else {
|
||||
buf.Append(beep.Resample(3, format.SampleRate, sampleRate, streamer))
|
||||
}
|
||||
|
||||
mtx.Lock()
|
||||
sounds[strings.Split(filepath.Base(path), ".")[0]] = buf
|
||||
mtx.Unlock()
|
||||
}
|
||||
}()
|
||||
|
||||
return nil
|
||||
})
|
||||
@ -81,6 +102,8 @@ func InitAudio() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
|
||||
speaker.Play(music)
|
||||
|
||||
enabled = true
|
||||
|
||||
@ -8,6 +8,8 @@ import (
|
||||
"github.com/BigJk/end_of_eden/gen/faces"
|
||||
"github.com/BigJk/end_of_eden/ui/menus/gameview"
|
||||
"github.com/BigJk/end_of_eden/ui/menus/mainmenu"
|
||||
"github.com/BigJk/end_of_eden/ui/style"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
zone "github.com/lrstanley/bubblezone"
|
||||
"github.com/samber/lo"
|
||||
"golang.design/x/clipboard"
|
||||
@ -21,6 +23,7 @@ import (
|
||||
)
|
||||
|
||||
var prog *tea.Program
|
||||
var loadStyle = lipgloss.NewStyle().Bold(true).Italic(true).Foreground(style.BaseGray)
|
||||
|
||||
func main() {
|
||||
audioFlag := flag.Bool("audio", true, "disable audio")
|
||||
@ -30,24 +33,36 @@ func main() {
|
||||
testGameState := flag.String("game_state", "", "test game state")
|
||||
flag.Parse()
|
||||
|
||||
fmt.Println(lipgloss.NewStyle().Bold(true).Foreground(style.BaseRed).Render("End Of Eden"))
|
||||
|
||||
// Init clipboard
|
||||
if err := clipboard.Init(); err != nil {
|
||||
panic(err)
|
||||
fmt.Println(loadStyle.Render("Initializing Clipboard. Please wait..."))
|
||||
{
|
||||
if err := clipboard.Init(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
fmt.Println(loadStyle.Render("Done!"))
|
||||
|
||||
// Init audio
|
||||
if *audioFlag {
|
||||
fmt.Println(loadStyle.Render("Initializing audio. Please wait..."))
|
||||
audio.InitAudio()
|
||||
audio.PlayMusic("theme")
|
||||
audio.PlayMusic("planet_mining")
|
||||
fmt.Println(loadStyle.Render("Done!"))
|
||||
}
|
||||
|
||||
// Init face generator
|
||||
if err := faces.InitGlobal("./assets/gen/faces"); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println(loadStyle.Render("Initializing Proc-Gen. Please wait..."))
|
||||
{
|
||||
// Init face generator
|
||||
if err := faces.InitGlobal("./assets/gen/faces"); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Init other gens
|
||||
gen.InitGen()
|
||||
// Init other gens
|
||||
gen.InitGen()
|
||||
}
|
||||
fmt.Println(loadStyle.Render("Done!"))
|
||||
|
||||
// Redirect log to file
|
||||
_ = os.Mkdir("./logs", 0777)
|
||||
|
||||
@ -161,6 +161,11 @@ fun = require "fun"
|
||||
return 0
|
||||
}))
|
||||
|
||||
l.SetGlobal("play_music", l.NewFunction(func(state *lua.LState) int {
|
||||
audio.PlayMusic(state.ToString(1))
|
||||
return 0
|
||||
}))
|
||||
|
||||
// Game State
|
||||
|
||||
l.SetGlobal("set_event", l.NewFunction(func(state *lua.LState) int {
|
||||
|
||||
@ -968,7 +968,11 @@ func (s *Session) RemoveStatusEffect(guid string) {
|
||||
|
||||
// GetActorStatusEffects returns the guids of all the status effects a certain actor owns.
|
||||
func (s *Session) GetActorStatusEffects(guid string) []string {
|
||||
return s.actors[guid].StatusEffects.ToSlice()
|
||||
if actor, ok := s.actors[guid]; ok {
|
||||
actor.StatusEffects.ToSlice()
|
||||
}
|
||||
|
||||
return []string{}
|
||||
}
|
||||
|
||||
// AddStatusEffectStacks increases the stacks of a certain status effect by guid.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user