diff options
| -rw-r--r-- | README.md | 7 | ||||
| -rw-r--r-- | gather_order.go | 1 | ||||
| -rw-r--r-- | go.mod | 5 | ||||
| -rw-r--r-- | go.sum | 14 | ||||
| -rw-r--r-- | main.go | 23 |
5 files changed, 42 insertions, 8 deletions
@@ -5,8 +5,11 @@ ## TODO - atm, stops moving if someone settles at destination -- save globally resources -- an entity may spawn other enities with a cost +- an entity may spawn other entities with a cost +- spawn order +- bigger map +- move the map view +- bug: select A, gather, move to B, (it stops), gather (no storage) ## Dependencies diff --git a/gather_order.go b/gather_order.go index c35f11f..b306cd1 100644 --- a/gather_order.go +++ b/gather_order.go @@ -40,7 +40,6 @@ func (*GatherOrder) updateGathering(gatherer *ResourceGatherer, source ResourceS gatherer.LastPickupTime = now gatherer.CurrentVolume += 1 source.Remaining -= 1 - slog.Info("gathered", slog.Int("current_volume", gatherer.CurrentVolume)) } func (o *GatherOrder) updateGathererFull(e *Entity, g *Game, gatherer *ResourceGatherer) { @@ -8,6 +8,7 @@ require ( github.com/hajimehoshi/ebiten/v2 v2.8.8 github.com/martinlehoux/kagamigo v0.6.1 golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b + golang.org/x/image v0.28.0 ) require ( @@ -16,14 +17,16 @@ require ( github.com/ebitengine/gomobile v0.0.0-20250329061421-6d0a8e981e4c // indirect github.com/ebitengine/hideconsole v1.0.0 // indirect github.com/ebitengine/purego v0.8.4 // indirect + github.com/go-text/typesetting v0.3.0 // indirect github.com/gofrs/uuid v4.4.0+incompatible // indirect github.com/jezek/xgb v1.1.1 // indirect github.com/kataras/i18n v0.0.8 // indirect - golang.org/x/image v0.28.0 // indirect + github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect golang.org/x/net v0.41.0 // indirect golang.org/x/sync v0.15.0 // indirect golang.org/x/sys v0.33.0 // indirect golang.org/x/text v0.26.0 // indirect + gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) @@ -10,18 +10,29 @@ github.com/ebitengine/hideconsole v1.0.0 h1:5J4U0kXF+pv/DhiXt5/lTz0eO5ogJ1iXb8Yj github.com/ebitengine/hideconsole v1.0.0/go.mod h1:hTTBTvVYWKBuxPr7peweneWdkUwEuHuB3C1R/ielR1A= github.com/ebitengine/purego v0.8.4 h1:CF7LEKg5FFOsASUj0+QwaXf8Ht6TlFxg09+S9wz0omw= github.com/ebitengine/purego v0.8.4/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= +github.com/go-text/typesetting v0.3.0 h1:OWCgYpp8njoxSRpwrdd1bQOxdjOXDj9Rqart9ML4iF4= +github.com/go-text/typesetting v0.3.0/go.mod h1:qjZLkhRgOEYMhU9eHBr3AR4sfnGJvOXNLt8yRAySFuY= github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA= github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/hajimehoshi/bitmapfont/v3 v3.2.0 h1:0DISQM/rseKIJhdF29AkhvdzIULqNIIlXAGWit4ez1Q= +github.com/hajimehoshi/bitmapfont/v3 v3.2.0/go.mod h1:8gLqGatKVu0pwcNCJguW3Igg9WQqVXF0zg/RvrGQWyg= github.com/hajimehoshi/ebiten/v2 v2.8.8 h1:xyMxOAn52T1tQ+j3vdieZ7auDBOXmvjUprSrxaIbsi8= github.com/hajimehoshi/ebiten/v2 v2.8.8/go.mod h1:durJ05+OYnio9b8q0sEtOgaNeBEQG7Yr7lRviAciYbs= github.com/jezek/xgb v1.1.1 h1:bE/r8ZZtSv7l9gk6nU0mYx51aXrvnyb44892TwSaqS4= github.com/jezek/xgb v1.1.1/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk= github.com/kataras/i18n v0.0.8 h1:thiDRqq4fN2sQOK5CwR5Yh1yT7swP6B3wnadILhqjhk= github.com/kataras/i18n v0.0.8/go.mod h1:M/yRAqQ3Y7z2oSpotxG/+nPrgsJLas6t0kEJfIJk98E= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/martinlehoux/kagamigo v0.6.1 h1:ggrpA/RyRwcRrS37gJPKrRQepo8kSTap6jbcB03EGU8= github.com/martinlehoux/kagamigo v0.6.1/go.mod h1:i+2rit5qkSYfpLxz4nuXuei7w5hgjxrauIBeZ1YFDGw= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ= +github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= @@ -38,8 +49,9 @@ golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U= +gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= @@ -3,6 +3,8 @@ package main import ( "age_of_empires/ecs" "age_of_empires/physics" + "bytes" + "fmt" "image" "image/color" _ "image/jpeg" @@ -11,9 +13,11 @@ import ( "github.com/hajimehoshi/ebiten/v2" "github.com/hajimehoshi/ebiten/v2/inpututil" + "github.com/hajimehoshi/ebiten/v2/text/v2" "github.com/hajimehoshi/ebiten/v2/vector" "github.com/martinlehoux/kagamigo/kcore" "golang.org/x/exp/slog" + "golang.org/x/image/font/gofont/goregular" ) type Action string @@ -35,6 +39,7 @@ type Game struct { CurrentAction Action Selection GlobalSelection ResourceAmount int + FaceSource *text.GoTextFaceSource } func DrawMove(screen *ebiten.Image, e *Entity) { @@ -171,6 +176,17 @@ func (g *Game) Draw(screen *ebiten.Image) { if g.Selection.IsActive { vector.StrokeRect(screen, float32(g.Selection.Start.X), float32(g.Selection.Start.Y), float32(cursor.X-g.Selection.Start.X), float32(cursor.Y-g.Selection.Start.Y), 10.0, color.RGBA{256 * 3 / 16, 256 * 3 / 16, 256 * 3 / 16, 256 / 4}, true) } + bannerHeight := float32(200) + vector.DrawFilledRect(screen, 0, 0, float32(3200), bannerHeight, color.White, true) + + resourceText := fmt.Sprintf("Resources: %d", g.ResourceAmount) + 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) } func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) { @@ -189,6 +205,9 @@ func main() { kcore.Expect(err, "failed to decode icon") ebiten.SetWindowIcon([]image.Image{iconImg}) game := &Game{} + s, err := text.NewGoTextFaceSource(bytes.NewReader(goregular.TTF)) + kcore.Expect(err, "failed to create font source") + game.FaceSource = s ironImage := NewFilledRectangleImage(physics.Point{X: 100, Y: 100}, color.RGBA{0x80, 0x80, 0x80, 0xff}) ironMine := Entity{ Position: ecs.C(physics.Point{X: 1000, Y: 1000}), @@ -225,7 +244,5 @@ func main() { } game.Entities = append(game.Entities, &person2) game.CurrentAction = Selecting - if err := ebiten.RunGame(game); err != nil { - panic(err) - } + kcore.Expect(ebiten.RunGame(game), "failed to run game") } |
