package main import ( rl "github.com/gen2brain/raylib-go/raylib" ) func main() { screenWidth := int32(800) screenHeight := int32(450) rl.InitWindow(screenWidth, screenHeight, "Bouncing Ball in Go - raylib") defer rl.CloseWindow() rl.SetTargetFPS(60) // Ball properties ballRadius := float32(20) ballPos := rl.NewVector2(float32(screenWidth)/2.0, float32(screenHeight)/2.0) ballSpeed := rl.NewVector2(4, 3) ballColor := rl.Red for !rl.WindowShouldClose() { // Update ballPos.X += ballSpeed.X ballPos.Y += ballSpeed.Y // Bounce on edges if ballPos.X >= float32(screenWidth)-ballRadius || ballPos.X <= ballRadius { ballSpeed.X *= -1 } if ballPos.Y >= float32(screenHeight)-ballRadius || ballPos.Y <= ballRadius { ballSpeed.Y *= -1 } // Draw rl.BeginDrawing() rl.ClearBackground(rl.RayWhite) rl.DrawText("Bouncing Ball Example", 10, 10, 20, rl.DarkGray) rl.DrawCircleV(ballPos, ballRadius, ballColor) rl.EndDrawing() } }