changed order of songs

This commit is contained in:
David Alasow 2017-12-23 10:14:41 +01:00
parent 291aff7aea
commit c40663d3f3

View File

@ -33,17 +33,23 @@ type character struct {
Color color.RGBA Color color.RGBA
} }
func check(err error) {
if err != nil {
log.Fatal(err)
}
}
var ( var (
m = character{`Me`, color.RGBA{200, 200, 255, 255}} m = character{`Me`, color.RGBA{200, 200, 255, 255}}
s = character{`Sylvie`, color.RGBA{200, 255, 200, 255}} s = character{`Sylvie`, color.RGBA{200, 255, 200, 255}}
d = character{``, color.RGBA{0, 255, 0, 0}} d = character{``, color.RGBA{0, 255, 0, 0}}
messages = []dialogue{ messages = []dialogue{
{d, `playSong ./Departures.mp3`}, {d, `playSong ./Hisoku.mp3`},
{s, `Hi there! How was class?`}, {s, `Hi there! How was class?`},
{m, `Good...`}, {m, `Good...`},
{d, `I can't bring myself to admit that it all went in one ear and out the other.`}, {d, `I can't bring myself to admit that it all went in one ear and out the other.`},
{s, `Are you going home now? Wanna walk back with me?`}, {s, `Are you going home now? Wanna walk back with me?`},
{d, `playSong ./Hisoku.mp3`}, {d, `playSong ./Departures.mp3`},
{m, `Sure!`}, {m, `Sure!`},
} }
mplusNormalFont font.Face mplusNormalFont font.Face
@ -60,17 +66,11 @@ func playSong(path string) {
audioPlayer.Close() audioPlayer.Close()
} }
f, err := ebitenutil.OpenFile(path) f, err := ebitenutil.OpenFile(path)
if err != nil { check(err)
log.Fatal(err)
}
d, err := mp3.Decode(audioContext, f) d, err := mp3.Decode(audioContext, f)
if err != nil { check(err)
log.Fatal(err)
}
audioPlayer, err = audio.NewPlayer(audioContext, d) audioPlayer, err = audio.NewPlayer(audioContext, d)
if err != nil { check(err)
log.Fatal(err)
}
audioPlayer.Play() audioPlayer.Play()
playingMusic = true playingMusic = true
} }
@ -78,32 +78,22 @@ func playSong(path string) {
func init() { func init() {
f, err := ebitenutil.OpenFile("./mplus-1p-regular.ttf") f, err := ebitenutil.OpenFile("./mplus-1p-regular.ttf")
if err != nil { check(err)
log.Fatal(err)
}
defer f.Close() defer f.Close()
b, err := ioutil.ReadAll(f) b, err := ioutil.ReadAll(f)
if err != nil { check(err)
log.Fatal(err)
}
tt, err := truetype.Parse(b) tt, err := truetype.Parse(b)
if err != nil { check(err)
log.Fatal(err)
}
const dpi = 72 const dpi = 72
mplusNormalFont = truetype.NewFace(tt, &truetype.Options{ mplusNormalFont = truetype.NewFace(tt, &truetype.Options{
Size: 24, Size: 24,
DPI: dpi, DPI: dpi,
Hinting: font.HintingFull, Hinting: font.HintingFull,
}) })
audioContext, err = audio.NewContext(sampleRate) audioContext, err = audio.NewContext(sampleRate)
if err != nil { check(err)
log.Fatal(err)
}
} }
func update(screen *ebiten.Image) error { func update(screen *ebiten.Image) error {
@ -145,9 +135,7 @@ func update(screen *ebiten.Image) error {
func main() { func main() {
var err error var err error
bg, _, err = ebitenutil.NewImageFromFile("./bg.jpg", ebiten.FilterNearest) bg, _, err = ebitenutil.NewImageFromFile("./bg.jpg", ebiten.FilterNearest)
if err != nil { check(err)
log.Fatal(err)
}
if err := ebiten.Run(update, screenWidth, screenHeight, 1, "Font (Ebiten Demo)"); err != nil { if err := ebiten.Run(update, screenWidth, screenHeight, 1, "Font (Ebiten Demo)"); err != nil {
log.Fatal(err) log.Fatal(err)
} }