Remove internal/conv
This sets font rendering back a little bit, but not much.
This commit is contained in:
@@ -6,22 +6,20 @@ import (
|
||||
"log"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
|
||||
"code.ur.gs/lupine/ordoor/internal/conv"
|
||||
"code.ur.gs/lupine/ordoor/internal/data"
|
||||
"code.ur.gs/lupine/ordoor/internal/assetstore"
|
||||
"code.ur.gs/lupine/ordoor/internal/ui"
|
||||
)
|
||||
|
||||
var (
|
||||
gamePath = flag.String("game-path", "./orig", "Path to a WH40K: Chaos Gate installation")
|
||||
objFile = flag.String("obj", "", "Path to a .obj file, e.g. ./orig/Obj/TZEENTCH.OBJ")
|
||||
objName = flag.String("obj", "", "Name of an .obj file, e.g. TZEENTCH")
|
||||
)
|
||||
|
||||
type env struct {
|
||||
obj *conv.Object
|
||||
obj *assetstore.Object
|
||||
step int
|
||||
|
||||
state state
|
||||
@@ -38,19 +36,19 @@ type state struct {
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
if *gamePath == "" || *objFile == "" {
|
||||
if *gamePath == "" || *objName == "" {
|
||||
flag.Usage()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
rawObj, err := data.LoadObject(*objFile)
|
||||
assets, err := assetstore.New(*gamePath)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to load %s: %v", *objFile, err)
|
||||
log.Fatal("Failed to set up asset store: %v", err)
|
||||
}
|
||||
|
||||
obj, err := conv.ConvertObject(rawObj, filepath.Base(*objFile))
|
||||
obj, err := assets.Object(*objName)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to convert %s: %v", *objFile, err)
|
||||
log.Fatalf("Failed to load %s: %v", *objName, err)
|
||||
}
|
||||
|
||||
state := state{
|
||||
@@ -64,7 +62,7 @@ func main() {
|
||||
lastState: state,
|
||||
}
|
||||
|
||||
win, err := ui.NewWindow("View Object: " + *objFile)
|
||||
win, err := ui.NewWindow("View Object: " + *objName)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -86,9 +84,9 @@ func main() {
|
||||
func (e *env) Update() error {
|
||||
if e.step == 0 || e.lastState != e.state {
|
||||
log.Printf(
|
||||
"new state: numSprites=%d sprite=%d zoom=%.2f, origin=%+v",
|
||||
len(e.obj.Sprites),
|
||||
"new state: sprite=%d/%d zoom=%.2f, origin=%+v",
|
||||
e.state.spriteIdx,
|
||||
e.obj.NumSprites,
|
||||
e.state.zoom,
|
||||
e.state.origin,
|
||||
)
|
||||
@@ -102,7 +100,10 @@ func (e *env) Update() error {
|
||||
}
|
||||
|
||||
func (e *env) Draw(screen *ebiten.Image) error {
|
||||
sprite := e.obj.Sprites[e.state.spriteIdx]
|
||||
sprite, err := e.obj.Sprite(e.state.spriteIdx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cam := ebiten.GeoM{}
|
||||
cam.Translate(float64(e.state.origin.X), float64(e.state.origin.Y)) // Move to origin
|
||||
@@ -119,8 +120,8 @@ func (e *env) changeSprite(by int) func() {
|
||||
e.state.spriteIdx = 0
|
||||
}
|
||||
|
||||
if e.state.spriteIdx > len(e.obj.Sprites)-1 {
|
||||
e.state.spriteIdx = len(e.obj.Sprites) - 1
|
||||
if e.state.spriteIdx > e.obj.NumSprites-1 {
|
||||
e.state.spriteIdx = e.obj.NumSprites - 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user