21 lines
691 B
Go
21 lines
691 B
Go
package main
|
|
|
|
import rl "github.com/gen2brain/raylib-go/raylib"
|
|
|
|
// Check if a point is over a rectangle
|
|
func overRect(p rl.Vector2, r rl.Rectangle) bool {
|
|
return p.X >= r.X && p.X <= r.X+r.Width && p.Y >= r.Y && p.Y <= r.Y+r.Height
|
|
}
|
|
|
|
// Check if a point is over a circle
|
|
func overCircle(p rl.Vector2, center rl.Vector2, radius float32) bool {
|
|
dx := p.X - center.X
|
|
dy := p.Y - center.Y
|
|
return (dx*dx + dy*dy) <= (radius * radius)
|
|
}
|
|
|
|
// Simplified helper to check if mouse is over a button-like rectangle
|
|
func overButton(mousePos rl.Vector2, x, y, w, h int32) bool {
|
|
r := rl.Rectangle{X: float32(x), Y: float32(y), Width: float32(w), Height: float32(h)}
|
|
return overRect(mousePos, r)
|
|
}
|