diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-02-17 08:00:18 +0100 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-02-17 08:00:18 +0100 |
| commit | 8da30c8dd8cc0860768ff0e54f0d092ac94013fa (patch) | |
| tree | 603cf87fe5a7cc0efc68b61443f46c6aa2ff4ce0 /main.go | |
| parent | f059ff3201599fed63302ac9e0ff315a05059922 (diff) | |
Selection is now Selectable
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -43,7 +43,7 @@ type Game struct { Position []physics.Point RelBounds []physics.Rectangle Image []*ebiten.Image - Selection []selection.Selection + Selectable []selection.Selectable Move []physics.Move Order []OrderKind PatrolOrder []PatrolOrder @@ -65,7 +65,7 @@ func (g *Game) Append(components Components, mask ecs.Mask) ecs.Entity { g.Position = append(g.Position, components.Position) g.RelBounds = append(g.RelBounds, components.RelBounds) g.Image = append(g.Image, components.Image) - g.Selection = append(g.Selection, components.Selection) + g.Selectable = append(g.Selectable, components.Selectable) g.Move = append(g.Move, components.Move) g.Order = append(g.Order, components.Order) g.ResourceGatherer = append(g.ResourceGatherer, components.ResourceGatherer) @@ -115,7 +115,7 @@ const ( func (g *Game) updateSelecting(cursor physics.Point, moveMap physics.MoveMap) { if inpututil.IsKeyJustReleased(ebiten.KeyEscape) { - g.GlobalSelection.Unselect(g.Selection) + g.GlobalSelection.Unselect(g.Selectable) } if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonLeft) { g.GlobalSelection.Start(cursor) @@ -130,9 +130,9 @@ func (g *Game) updateSelecting(cursor physics.Point, moveMap physics.MoveMap) { if inpututil.IsMouseButtonJustReleased(ebiten.MouseButtonLeft) { if g.GlobalSelection.IsActive(cursor) { if g.GlobalSelection.IsArea(cursor) { - g.GlobalSelection.SelectMultiple(cursor, g.Mask, g.Selection, g.Position, g.RelBounds) + g.GlobalSelection.SelectMultiple(cursor, g.Mask, g.Selectable, g.Position, g.RelBounds) } else { - g.GlobalSelection.SelectSingle(cursor, g.Mask, g.Selection, g.Position, g.RelBounds) + g.GlobalSelection.SelectSingle(cursor, g.Mask, g.Selectable, g.Position, g.RelBounds) } } } @@ -208,11 +208,11 @@ func main() { s, err := text.NewGoTextFaceSource(bytes.NewReader(goregular.TTF)) 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).WithSelection("square", selection.Building) + ironMineBuilder := NewEntityBuilder().WithSolid(NewFilledRectangleImage(physics.Point{X: 100, Y: 100}, color.RGBA{0x80, 0x80, 0x80, 0xff})).WithResourceSource(1000).WithSelectable("square", selection.Building) game.Append(ironMineBuilder.WithPosition(physics.Point{X: 1000, Y: 1000}).Build()) - townCenterBuilder := NewEntityBuilder().WithSolid(NewFilledRectangleImage(physics.Point{X: 100, Y: 100}, color.RGBA{0x0, 0x0, 0xff, 0xff})).WithResourceStorage().WithSelection("square", selection.Building).WithSpawn(NewSpawn(50, 1*time.Second)) + townCenterBuilder := NewEntityBuilder().WithSolid(NewFilledRectangleImage(physics.Point{X: 100, Y: 100}, color.RGBA{0x0, 0x0, 0xff, 0xff})).WithResourceStorage().WithSelectable("square", selection.Building).WithSpawn(NewSpawn(50, 1*time.Second)) townCenter := game.Append(townCenterBuilder.WithPosition(physics.Point{X: 1000, Y: 2000}).Build()) - game.UnitBuilder = NewEntityBuilder().WithSolid(NewFilledCircleImage(100, color.White)).WithSelection("round", selection.Unit).WithMove().WithOrder().WithResourceGatherer(15) + game.UnitBuilder = NewEntityBuilder().WithSolid(NewFilledCircleImage(100, color.White)).WithSelectable("round", selection.Unit).WithMove().WithOrder().WithResourceGatherer(15) for i := 0; i < 0; i++ { spawnPosition, _ := physics.Closest(game.Position[townCenter], physics.AdjacentPoints(game.Position[townCenter]), game.getMoveMap()) game.Append(game.UnitBuilder.WithPosition(spawnPosition).Build()) |
