31 lines
580 B
Go
31 lines
580 B
Go
package render
|
|
|
|
import (
|
|
"image/color"
|
|
|
|
rl "github.com/gen2brain/raylib-go/raylib"
|
|
)
|
|
|
|
func DrawText(x, y, size int32, text string, col color.RGBA) {
|
|
destRect := rl.Rectangle{
|
|
X: float32(x),
|
|
Y: float32(y),
|
|
Width: float32(size),
|
|
Height: float32(size),
|
|
}
|
|
|
|
for _, ch := range text {
|
|
if ch == ' ' {
|
|
destRect.X += float32(size)
|
|
continue
|
|
}
|
|
|
|
tile := font.GetTile(ch)
|
|
if tile == nil {
|
|
destRect.X += float32(size)
|
|
continue
|
|
}
|
|
rl.DrawTexturePro(texture, tile.GetTexRect(), destRect, rl.Vector2Zero(), 0, col)
|
|
destRect.X += float32(size)
|
|
}
|
|
}
|