everything I got

This commit is contained in:
MrDonuts
2023-11-19 20:53:35 -05:00
commit a875a4ed57
45 changed files with 903 additions and 0 deletions

BIN
assets/.DS_Store vendored Normal file

Binary file not shown.

71
assets/audio.go Normal file
View File

@@ -0,0 +1,71 @@
package assets
import (
"bytes"
"embed"
"fmt"
"io/fs"
"log"
"github.com/hajimehoshi/ebiten/v2/audio"
"github.com/hajimehoshi/ebiten/v2/audio/wav"
)
//go:embed *
//go:embed */*
var embeddedFiles embed.FS
var sampleRate = 44100
var audioContext = audio.NewContext(sampleRate)
var songChoice = 2
var SongTracks = loadTracksForSong(songChoice)
func loadTracksForSong(sng int) map[int]*audio.Player {
tempMap := make(map[int]*audio.Player)
for i := 1; i <= 10; i++ {
tempMap[i] = LoadWavAudioFile(fmt.Sprintf("audio/song0%d/track%02d.wav", sng, i), true)
}
return tempMap
}
var SFXLibrary = map[string]*audio.Player{
"newLevel": LoadWavAudioFile("audio/portal2.wav", false),
"colourMatch": LoadWavAudioFile("audio/portal.wav", false),
"gameOver": LoadWavAudioFile("audio/gameOver.wav", false),
}
func LoadWavAudioFile(filePath string, loop bool) *audio.Player {
audioData, err := fs.ReadFile(embeddedFiles, filePath)
if err != nil {
log.Fatal(err)
}
stream, err := wav.DecodeWithSampleRate(sampleRate, bytes.NewReader(audioData))
if err != nil {
log.Fatalf("failed to decode audio: %v", err)
}
var player *audio.Player
if loop {
lengthOfAudioData := int64(len(audioData))
loopingStream := audio.NewInfiniteLoop(stream, lengthOfAudioData)
player, err = audioContext.NewPlayer(loopingStream)
} else {
player, err = audioContext.NewPlayer(stream)
}
if err != nil {
log.Fatal(err)
}
return player
}
func SilenceSongTracks() {
for _, song := range SongTracks {
song.SetVolume(0)
}
}

BIN
assets/audio/.DS_Store vendored Normal file

Binary file not shown.

BIN
assets/audio/gameOver.wav Normal file

Binary file not shown.

BIN
assets/audio/portal.wav Normal file

Binary file not shown.

BIN
assets/audio/portal2.wav Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
assets/audio/song02/.DS_Store vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

37
assets/fonts.go Normal file
View File

@@ -0,0 +1,37 @@
package assets
import (
"embed"
"log"
"golang.org/x/image/font"
"golang.org/x/image/font/opentype"
)
//go:embed *
var FontFiles embed.FS
var fontFace font.Face
func LoadFontFace(fileName string, size float64) font.Face {
fontBytes, err := FontFiles.ReadFile(fileName)
if err != nil {
log.Fatal(err)
}
tt, err := opentype.Parse(fontBytes)
if err != nil {
log.Fatal(err)
}
const dpi = 144
fontFace, err = opentype.NewFace(tt, &opentype.FaceOptions{
Size: size,
DPI: dpi,
Hinting: font.HintingNone,
})
if err != nil {
log.Fatal(err)
}
return fontFace
}

BIN
assets/fonts/mechanical.otf Normal file

Binary file not shown.

BIN
assets/fonts/robot.otf Normal file

Binary file not shown.