aboutsummaryrefslogtreecommitdiff
path: root/go/ui/mapView.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/ui/mapView.go')
-rw-r--r--go/ui/mapView.go43
1 files changed, 27 insertions, 16 deletions
diff --git a/go/ui/mapView.go b/go/ui/mapView.go
index 10929f68..c292d526 100644
--- a/go/ui/mapView.go
+++ b/go/ui/mapView.go
@@ -13,7 +13,7 @@ import (
)
const (
- PERMANENT_WIDTH int = 40
+ PERMANENT_WIDTH int = 40
PERMANENT_HEIGHT int = 40
TILE_WIDTH int = 50
@@ -21,15 +21,15 @@ const (
)
type MapView struct {
- gameState *game.State
- mapLayer *ebiten.Image
- permanentsLayer *ebiten.Image
- tileHighlights []game.Position
- permanentsHighlights []*game.Permanent
+ gameState *game.State
+ mapLayer *ebiten.Image
+ permanentsLayer *ebiten.Image
+ tileHighlights []game.Position
+ permanentsHighlights []game.Permanent
}
func NewMapView(g *game.State) *MapView {
- vw := MapView{g, nil, nil, []game.Position{}, []*game.Permanent{}}
+ vw := MapView{g, nil, nil, []game.Position{}, []game.Permanent{}}
return &vw
}
@@ -131,16 +131,27 @@ func (vw *MapView) drawPermanentsLayer(screen *ebiten.Image) {
vw.permanentsLayer = vw.newLayerImage()
for _, p := range vw.gameState.Permanents {
- permanentSymbol := assets.GetSymbol(strings.ToLower(p.Card.Name))
+ permanentSymbol := assets.GetSymbol(strings.ToLower(p.GetCard().Name))
// TODO: Implement generic symbols
if permanentSymbol == nil {
continue
}
+ t := p.GetTile()
+ x_px := t.Position.X*TILE_WIDTH + (TILE_WIDTH-PERMANENT_WIDTH)/2
+ y_px := t.Position.Y*TILE_HEIGHT + (TILE_HEIGHT-PERMANENT_HEIGHT)/2
+
op := &ebiten.DrawImageOptions{}
- x_px := p.Tile.Position.X * TILE_WIDTH + (TILE_WIDTH - PERMANENT_WIDTH) / 2
- y_px := p.Tile.Position.Y * TILE_HEIGHT + (TILE_HEIGHT - PERMANENT_HEIGHT) / 2
op.GeoM.Translate(float64(x_px), float64(y_px))
+ op.ColorM.ScaleWithColor(p.GetController().Color)
+
+ for _, h := range vw.permanentsHighlights {
+ if p == h {
+ op.ColorM.Scale(255, 0.5, 0.5, 1)
+ break
+ }
+ }
+
vw.permanentsLayer.DrawImage(permanentSymbol, op)
}
}
@@ -163,8 +174,8 @@ func (vw *MapView) FindObjectAt(x_px, y_px int) interface{} {
y := y_px / TILE_HEIGHT
// TODO: detect if a permanent or the containing tile was selected
- for _, u := range vw.gameState.Units {
- pos := u.Tile.Position
+ for _, u := range vw.gameState.Permanents {
+ pos := u.GetTile().Position
if pos.X == x && pos.Y == y {
return u
}
@@ -198,15 +209,15 @@ func (vw *MapView) ClearTileHighlights() {
vw.HighlightTiles([]*game.Tile{})
}
-func (vw *MapView) HighlightPermanents(permanents []*game.Permanent) {
+func (vw *MapView) HighlightPermanents(permanents []game.Permanent) {
vw.ForceRedraw()
vw.permanentsHighlights = permanents
}
-func (vw *MapView) HighlightPermanent(p *game.Permanent) {
- vw.HighlightPermanents([]*game.Permanent{p})
+func (vw *MapView) HighlightPermanent(p game.Permanent) {
+ vw.HighlightPermanents([]game.Permanent{p})
}
func (vw *MapView) ClearPermanentsHighlights() {
- vw.HighlightPermanents([]*game.Permanent{})
+ vw.HighlightPermanents([]game.Permanent{})
}