gg/cmd/test/main.go

91 lines
1.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"vultras.su/core/gg"
"github.com/hajimehoshi/ebiten/v2/examples/resources/images"
"github.com/hajimehoshi/ebiten/v2/examples/resources/fonts"
_ "github.com/silbinarywolf/preferdiscretegpu"
"bytes"
"log"
"fmt"
)
type Context = gg.Context
const (
HighestL gg.Layer = -iota
DebugL
TriangleL
PlayerL
RectL
LowestL
)
var (
playerImg *gg.Image
player *Player
rectMove gg.Rectangle
rect *Rect
tri *Tri
)
func main() {
e := gg.NewEngine(&gg.WindowConfig{
Title: "Test title",
Width: 720,
Height: 480,
VSync: true,
Fullscreen: true,
})
var err error
playerImg, err = gg.LoadImage(bytes.NewReader(images.Runner_png))
if err != nil {
log.Fatal(err)
}
rect = NewRect()
player = NewPlayer()
tri = NewTri()
e.Spawn(&Debug{})
e.Spawn(player)
e.Spawn(rect)
e.Spawn(tri)
circle := &gg.Circle{}
circle.Transform = gg.T()
circle.Rotation = 300
circle.Color = gg.Rgba(1, 1, 1, 1)
circle.Antialias = true
circle.Layer = HighestL
circle.Visible = true
//e.Spawn(circle)
txt := &gg.Text{}
txt.Transform = gg.T()
//txt.Position = gg.V2(400)
txt.Color = gg.Rgba(1, 1, 1, 1)
txt.Layer = HighestL
txt.Visible = true
txt.Text = "Hello, World!\nПривет, Мир!"
txt.Face, err = gg.MakeFaceFromTtf(
bytes.NewReader(fonts.MPlus1pRegular_ttf),
&gg.TtfFaceOptions{
Size: 32,
DPI: 72,
Hinting: gg.FontHintingNone,
},
)
if err != nil {
panic(err)
}
e.Spawn(txt)
//fmt.Println(rect.GetLayer(), player.GetLayer())
fmt.Println("Starting...")
err = e.Run()
if err != nil {
panic(err)
}
}