Initial commit
This commit is contained in:
commit
0245a5cb43
22 changed files with 610 additions and 0 deletions
31
engine/render/text.go
Normal file
31
engine/render/text.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
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)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue