Started texture mapped fonts demo.

This commit is contained in:
Marvin Blum
2016-05-21 13:53:27 +02:00
parent 67571025e9
commit 6e368f066f
3 changed files with 83 additions and 0 deletions

55
demo/text/text.go Normal file
View File

@@ -0,0 +1,55 @@
package main
import (
"github.com/DeKugelschieber/go-game"
)
const (
gopher_path = "src/github.com/DeKugelschieber/go-game/demo/sprite/assets/gopher.png"
)
type Game struct{}
func (g *Game) Setup() {
// load texture
_, err := goga.LoadRes(gopher_path)
if err != nil {
panic(err)
}
// create sprite
tex, err := goga.GetTex("gopher.png")
if err != nil {
panic(err)
}
sprite := goga.NewSprite(tex)
renderer, ok := goga.GetSystemByName("spriteRenderer").(*goga.SpriteRenderer)
if !ok {
panic("Could not find renderer")
}
renderer.Add(sprite.Actor, sprite.Pos2D, sprite.Tex)
culling, ok := goga.GetSystemByName("culling2d").(*goga.Culling2D)
if !ok {
panic("Could not find culling")
}
culling.Add(sprite.Actor, sprite.Pos2D)
}
func (g *Game) Update(delta float64) {}
func main() {
game := Game{}
options := goga.RunOptions{ClearColor: goga.Vec4{1, 1, 1, 0},
Resizable: true,
SetViewportOnResize: true,
ExitOnClose: true}
goga.Run(&game, &options)
}