forked from gen2brain/raylib-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (28 loc) · 770 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"github.com/gen2brain/raylib-go/raylib"
)
func main() {
rl.InitWindow(800, 450, "raylib [audio] example - sound loading and playing")
rl.InitAudioDevice()
fxWav := rl.LoadSound("weird.wav")
fxOgg := rl.LoadSound("tanatana.ogg")
rl.SetTargetFPS(60)
for !rl.WindowShouldClose() {
if rl.IsKeyPressed(rl.KeySpace) {
rl.PlaySound(fxWav)
}
if rl.IsKeyPressed(rl.KeyEnter) {
rl.PlaySound(fxOgg)
}
rl.BeginDrawing()
rl.ClearBackground(rl.RayWhite)
rl.DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, rl.LightGray)
rl.DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, rl.LightGray)
rl.EndDrawing()
}
rl.UnloadSound(fxWav)
rl.UnloadSound(fxOgg)
rl.CloseAudioDevice()
rl.CloseWindow()
}