mirror of
https://github.com/Kugelschieber/go-game.git
synced 2026-01-18 14:50:28 +00:00
Compare commits
1 Commits
0.2_beta
...
text-rende
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e368f066f |
28
demo/text/assets/dejavu.json
Normal file
28
demo/text/assets/dejavu.json
Normal file
@@ -0,0 +1,28 @@
|
||||
[
|
||||
{
|
||||
"char": "A",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"char": "b",
|
||||
"x": 1,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"char": "e",
|
||||
"x": 2,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"char": "r",
|
||||
"x": 0,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"char": "'",
|
||||
"x": 3,
|
||||
"y": 0,
|
||||
"offset": 0.5
|
||||
}
|
||||
]
|
||||
BIN
demo/text/assets/dejavu.png
Normal file
BIN
demo/text/assets/dejavu.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
55
demo/text/text.go
Normal file
55
demo/text/text.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user