Get character stats (kind of) displaying in-scenario

This commit is contained in:
2020-06-13 18:11:45 +01:00
parent 3b7cfb6ecc
commit 4d336b9189
11 changed files with 137 additions and 24 deletions

View File

@@ -36,7 +36,7 @@ func (s *Scenario) Update(screenX, screenY int) error {
}
// FIXME: adjust for Z level
s.selectedCell = screenPos.ToISO()
s.highlightedCell = screenPos.ToISO()
return nil
}
@@ -112,7 +112,7 @@ func (s *Scenario) Draw(screen *ebiten.Image) error {
}
op := ebiten.DrawImageOptions{}
geo := s.geoForCoords(int(s.selectedCell.X), int(s.selectedCell.Y), 0)
geo := s.geoForCoords(int(s.highlightedCell.X), int(s.highlightedCell.Y), 0)
op.GeoM = geo
op.GeoM.Translate(-209, -332)
op.GeoM.Translate(float64(spr.Rect.Min.X), float64(spr.Rect.Min.Y))
@@ -125,7 +125,7 @@ func (s *Scenario) Draw(screen *ebiten.Image) error {
x1, y1 := geo.Apply(0, 0)
ebitenutil.DebugPrintAt(
screen,
fmt.Sprintf("(%d,%d)", int(s.selectedCell.X), int(s.selectedCell.Y)),
fmt.Sprintf("(%d,%d)", int(s.highlightedCell.X), int(s.highlightedCell.Y)),
int(x1),
int(y1),
)

View File

@@ -1,6 +1,8 @@
package scenario
import (
"log"
"code.ur.gs/lupine/ordoor/internal/maps"
)
@@ -10,8 +12,23 @@ type CellPoint struct {
}
func (s *Scenario) CellAtCursor() (*maps.Cell, CellPoint) {
cell := s.area.Cell(int(s.selectedCell.X), int(s.selectedCell.Y), 0)
return cell, CellPoint{IsoPt: s.selectedCell, Z: 0}
cell := s.area.Cell(int(s.highlightedCell.X), int(s.highlightedCell.Y), 0)
return cell, CellPoint{IsoPt: s.highlightedCell, Z: 0}
}
func (s *Scenario) HighlightedCharacter() *maps.Character {
// FIXME: characters are always at zIdx 0 right now
return s.area.CharacterAt(int(s.highlightedCell.X), int(s.highlightedCell.Y), 0)
}
func (s *Scenario) SelectedCharacter() *maps.Character {
return s.selectedCharacter
}
func (s *Scenario) SelectHighlightedCharacter() {
chr := s.HighlightedCharacter()
log.Printf("Selected character %s", chr)
s.selectedCharacter = chr
}
func (s *Scenario) ChangeZIdx(by int) {

View File

@@ -5,15 +5,18 @@ import (
"image"
"code.ur.gs/lupine/ordoor/internal/assetstore"
"code.ur.gs/lupine/ordoor/internal/maps"
)
type Scenario struct {
area *assetstore.Map
specials *assetstore.Object
tick int
turn int
selectedCell IsoPt
tick int
turn int
highlightedCell IsoPt
selectedCharacter *maps.Character
// All these must be modified by user actions somehow.
// TODO: extract into the idea of a viewport passed to Update / Draw somehow?