Update C sources, add new functions and rename package to
This commit is contained in:
parent
391c25482d
commit
08aa518a46
156 changed files with 34542 additions and 19573 deletions
|
@ -7,27 +7,27 @@ import (
|
|||
const maxCircles = 64
|
||||
|
||||
type circleWave struct {
|
||||
Position raylib.Vector2
|
||||
Position rl.Vector2
|
||||
Radius float32
|
||||
Alpha float32
|
||||
Speed float32
|
||||
Color raylib.Color
|
||||
Color rl.Color
|
||||
}
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
raylib.SetConfigFlags(raylib.FlagMsaa4xHint) // NOTE: Try to enable MSAA 4X
|
||||
rl.SetConfigFlags(rl.FlagMsaa4xHint) // NOTE: Try to enable MSAA 4X
|
||||
|
||||
raylib.InitWindow(screenWidth, screenHeight, "raylib [audio] example - module playing (streaming)")
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [audio] example - module playing (streaming)")
|
||||
|
||||
raylib.InitAudioDevice()
|
||||
rl.InitAudioDevice()
|
||||
|
||||
colors := []raylib.Color{
|
||||
raylib.Orange, raylib.Red, raylib.Gold, raylib.Lime, raylib.Blue,
|
||||
raylib.Violet, raylib.Brown, raylib.LightGray, raylib.Pink,
|
||||
raylib.Yellow, raylib.Green, raylib.SkyBlue, raylib.Purple, raylib.Beige,
|
||||
colors := []rl.Color{
|
||||
rl.Orange, rl.Red, rl.Gold, rl.Lime, rl.Blue,
|
||||
rl.Violet, rl.Brown, rl.LightGray, rl.Pink,
|
||||
rl.Yellow, rl.Green, rl.SkyBlue, rl.Purple, rl.Beige,
|
||||
}
|
||||
|
||||
circles := make([]circleWave, maxCircles)
|
||||
|
@ -36,47 +36,47 @@ func main() {
|
|||
c := circleWave{}
|
||||
|
||||
c.Alpha = 0
|
||||
c.Radius = float32(raylib.GetRandomValue(10, 40))
|
||||
c.Radius = float32(rl.GetRandomValue(10, 40))
|
||||
|
||||
x := raylib.GetRandomValue(int32(c.Radius), screenWidth-int32(c.Radius))
|
||||
y := raylib.GetRandomValue(int32(c.Radius), screenHeight-int32(c.Radius))
|
||||
c.Position = raylib.NewVector2(float32(x), float32(y))
|
||||
x := rl.GetRandomValue(int32(c.Radius), screenWidth-int32(c.Radius))
|
||||
y := rl.GetRandomValue(int32(c.Radius), screenHeight-int32(c.Radius))
|
||||
c.Position = rl.NewVector2(float32(x), float32(y))
|
||||
|
||||
c.Speed = float32(raylib.GetRandomValue(1, 100)) / 20000.0
|
||||
c.Color = colors[raylib.GetRandomValue(0, int32(len(colors)-1))]
|
||||
c.Speed = float32(rl.GetRandomValue(1, 100)) / 20000.0
|
||||
c.Color = colors[rl.GetRandomValue(0, int32(len(colors)-1))]
|
||||
|
||||
circles[i] = c
|
||||
}
|
||||
|
||||
xm := raylib.LoadMusicStream("mini1111.xm")
|
||||
raylib.PlayMusicStream(xm)
|
||||
xm := rl.LoadMusicStream("mini1111.xm")
|
||||
rl.PlayMusicStream(xm)
|
||||
|
||||
pause := false
|
||||
|
||||
raylib.SetTargetFPS(60)
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !raylib.WindowShouldClose() {
|
||||
raylib.UpdateMusicStream(xm) // Update music buffer with new stream data
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.UpdateMusicStream(xm) // Update music buffer with new stream data
|
||||
|
||||
// Restart music playing (stop and play)
|
||||
if raylib.IsKeyPressed(raylib.KeySpace) {
|
||||
raylib.StopMusicStream(xm)
|
||||
raylib.PlayMusicStream(xm)
|
||||
if rl.IsKeyPressed(rl.KeySpace) {
|
||||
rl.StopMusicStream(xm)
|
||||
rl.PlayMusicStream(xm)
|
||||
}
|
||||
|
||||
// Pause/Resume music playing
|
||||
if raylib.IsKeyPressed(raylib.KeyP) {
|
||||
if rl.IsKeyPressed(rl.KeyP) {
|
||||
pause = !pause
|
||||
|
||||
if pause {
|
||||
raylib.PauseMusicStream(xm)
|
||||
rl.PauseMusicStream(xm)
|
||||
} else {
|
||||
raylib.ResumeMusicStream(xm)
|
||||
rl.ResumeMusicStream(xm)
|
||||
}
|
||||
}
|
||||
|
||||
// Get timePlayed scaled to bar dimensions
|
||||
timePlayed := int32(raylib.GetMusicTimePlayed(xm)/raylib.GetMusicTimeLength(xm)*float32(screenWidth-40)) * 2
|
||||
timePlayed := int32(rl.GetMusicTimePlayed(xm)/rl.GetMusicTimeLength(xm)*float32(screenWidth-40)) * 2
|
||||
|
||||
// Color circles animation
|
||||
for i := maxCircles - 1; (i >= 0) && !pause; i-- {
|
||||
|
@ -89,33 +89,33 @@ func main() {
|
|||
|
||||
if circles[i].Alpha <= 0.0 {
|
||||
circles[i].Alpha = 0.0
|
||||
circles[i].Radius = float32(raylib.GetRandomValue(10, 40))
|
||||
circles[i].Position.X = float32(raylib.GetRandomValue(int32(circles[i].Radius), screenWidth-int32(circles[i].Radius)))
|
||||
circles[i].Position.Y = float32(raylib.GetRandomValue(int32(circles[i].Radius), screenHeight-int32(circles[i].Radius)))
|
||||
circles[i].Color = colors[raylib.GetRandomValue(0, 13)]
|
||||
circles[i].Speed = float32(raylib.GetRandomValue(1, 100)) / 20000.0
|
||||
circles[i].Radius = float32(rl.GetRandomValue(10, 40))
|
||||
circles[i].Position.X = float32(rl.GetRandomValue(int32(circles[i].Radius), screenWidth-int32(circles[i].Radius)))
|
||||
circles[i].Position.Y = float32(rl.GetRandomValue(int32(circles[i].Radius), screenHeight-int32(circles[i].Radius)))
|
||||
circles[i].Color = colors[rl.GetRandomValue(0, 13)]
|
||||
circles[i].Speed = float32(rl.GetRandomValue(1, 100)) / 20000.0
|
||||
}
|
||||
}
|
||||
|
||||
raylib.BeginDrawing()
|
||||
rl.BeginDrawing()
|
||||
|
||||
raylib.ClearBackground(raylib.RayWhite)
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
for i := maxCircles - 1; i >= 0; i-- {
|
||||
raylib.DrawCircleV(circles[i].Position, float32(circles[i].Radius), raylib.Fade(circles[i].Color, circles[i].Alpha))
|
||||
rl.DrawCircleV(circles[i].Position, float32(circles[i].Radius), rl.Fade(circles[i].Color, circles[i].Alpha))
|
||||
}
|
||||
|
||||
// Draw time bar
|
||||
raylib.DrawRectangle(20, screenHeight-20-12, screenWidth-40, 12, raylib.LightGray)
|
||||
raylib.DrawRectangle(20, screenHeight-20-12, timePlayed, 12, raylib.Maroon)
|
||||
raylib.DrawRectangleLines(20, screenHeight-20-12, screenWidth-40, 12, raylib.Gray)
|
||||
rl.DrawRectangle(20, screenHeight-20-12, screenWidth-40, 12, rl.LightGray)
|
||||
rl.DrawRectangle(20, screenHeight-20-12, timePlayed, 12, rl.Maroon)
|
||||
rl.DrawRectangleLines(20, screenHeight-20-12, screenWidth-40, 12, rl.Gray)
|
||||
|
||||
raylib.EndDrawing()
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
raylib.UnloadMusicStream(xm)
|
||||
rl.UnloadMusicStream(xm)
|
||||
|
||||
raylib.CloseAudioDevice()
|
||||
rl.CloseAudioDevice()
|
||||
|
||||
raylib.CloseWindow()
|
||||
rl.CloseWindow()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue