diff options
| -rw-r--r-- | draw.go | 26 | ||||
| -rw-r--r-- | fonts/Cinzel-VariableFont_wght.ttf | bin | 0 -> 126348 bytes | |||
| -rw-r--r-- | main.go | 6 | ||||
| -rw-r--r-- | physics/move.go | 2 |
4 files changed, 15 insertions, 19 deletions
@@ -13,6 +13,12 @@ import ( "github.com/hajimehoshi/ebiten/v2/vector" ) +func (g *Game) font(size float64) *text.GoTextFace { + f := &text.GoTextFace{Source: g.FaceSource, Size: size} + f.SetVariation(text.MustParseTag("wght"), 500) + return f +} + func (g *Game) Draw(screen *ebiten.Image) { x, y := ebiten.CursorPosition() cursor := physics.Point{X: x, Y: y} @@ -38,10 +44,7 @@ func (g *Game) Draw(screen *ebiten.Image) { op := &text.DrawOptions{} op.GeoM.Translate(float64(position.X+5), float64(position.Y+30)) op.ColorScale.ScaleWithColor(color.White) - text.Draw(screen, resourceText, &text.GoTextFace{ - Source: g.FaceSource, - Size: 40, - }, op) + text.Draw(screen, resourceText, g.font(40), op) } if mask&ecs.CM_Spawn == ecs.CM_Spawn { spawn := g.Spawn[i] @@ -49,10 +52,7 @@ func (g *Game) Draw(screen *ebiten.Image) { op := &text.DrawOptions{} op.GeoM.Translate(float64(position.X+5), float64(position.Y+70)) op.ColorScale.ScaleWithColor(color.White) - text.Draw(screen, spawnText, &text.GoTextFace{ - Source: g.FaceSource, - Size: 40, - }, op) + text.Draw(screen, spawnText, g.font(40), op) if spawn.SpawnTarget.Ok { spawnTarget := spawn.SpawnTarget.Value vector.DrawFilledCircle(screen, float32(spawnTarget.X+50), float32(spawnTarget.Y+50), 30, Red, true) @@ -91,10 +91,7 @@ func drawTopBanner(screen *ebiten.Image, g *Game) { op := &text.DrawOptions{} op.GeoM.Translate(25, 25) op.ColorScale.ScaleWithColor(color.Black) - text.Draw(screen, resourceText, &text.GoTextFace{ - Source: g.FaceSource, - Size: 100, - }, op) + text.Draw(screen, resourceText, g.font(100), op) } func drawBottomBanner(screen *ebiten.Image, g *Game) { @@ -114,8 +111,5 @@ func drawBottomBanner(screen *ebiten.Image, g *Game) { op := &text.DrawOptions{} op.GeoM.Translate(25, float64(float32(bannerTop)+25)) op.ColorScale.ScaleWithColor(color.Black) - text.Draw(screen, shortcuts, &text.GoTextFace{ - Source: g.FaceSource, - Size: 60, - }, op) + text.Draw(screen, shortcuts, g.font(60), op) } diff --git a/fonts/Cinzel-VariableFont_wght.ttf b/fonts/Cinzel-VariableFont_wght.ttf Binary files differnew file mode 100644 index 0000000..0ae41bc --- /dev/null +++ b/fonts/Cinzel-VariableFont_wght.ttf @@ -18,7 +18,7 @@ import ( "github.com/hajimehoshi/ebiten/v2/text/v2" "github.com/martinlehoux/kagamigo/kcore" "golang.org/x/exp/slog" - "golang.org/x/image/font/gofont/goregular" + ) type Action string @@ -205,7 +205,9 @@ func main() { game := &Game{ ResourceAmount: 150, } - s, err := text.NewGoTextFaceSource(bytes.NewReader(goregular.TTF)) + fontData, err := os.ReadFile("fonts/Cinzel-VariableFont_wght.ttf") + kcore.Expect(err, "failed to read font") + s, err := text.NewGoTextFaceSource(bytes.NewReader(fontData)) kcore.Expect(err, "failed to create font source") game.FaceSource = s ironMineBuilder := NewEntityBuilder().WithSolid(NewFilledRectangleImage(physics.Point{X: 100, Y: 100}, color.RGBA{0x80, 0x80, 0x80, 0xff})).WithResourceSource(1000).WithSelectable("square", selection.Building) diff --git a/physics/move.go b/physics/move.go index b898ec7..78b97b7 100644 --- a/physics/move.go +++ b/physics/move.go @@ -194,7 +194,7 @@ func UpdateMoveSystem(moveMap MoveMap, masks []ecs.Mask, moves []Move, positions } // About to snap to next cell — check it's still free if moveMap.Blocked[next] { - slog.Info("cell blocked on arrival, repathing", slog.String("next", next.String())) + slog.Debug("cell blocked on arrival, repathing", slog.String("next", next.String())) path, ok := SearchPath(*position, move.Destination, moveMap) if !ok { slog.Info("no path found", slog.String("destination", move.Destination.String())) |
