Simplify bounds clipping a tiny bit
This commit is contained in:
@@ -22,6 +22,17 @@ type IsoPt struct {
|
|||||||
func (s *Scenario) Update(screenX, screenY int) error {
|
func (s *Scenario) Update(screenX, screenY int) error {
|
||||||
s.tick += 1
|
s.tick += 1
|
||||||
|
|
||||||
|
x, y := ebiten.CursorPosition()
|
||||||
|
screenPos := CartPt{
|
||||||
|
X: float64(s.Viewpoint.X + x),
|
||||||
|
Y: float64(s.Viewpoint.Y + y),
|
||||||
|
}
|
||||||
|
|
||||||
|
s.selectedCell = screenPos.ToISO()
|
||||||
|
|
||||||
|
// TODO: zoom support will need a camera
|
||||||
|
// FIXME: adjust for Z level
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,13 +44,15 @@ func (s *Scenario) Draw(screen *ebiten.Image) error {
|
|||||||
|
|
||||||
sw, sh := screen.Size()
|
sw, sh := screen.Size()
|
||||||
|
|
||||||
topLeft := CartPt{X: float64(s.Viewpoint.X), Y: float64(s.Viewpoint.Y)}.ToISO()
|
topLeft := CartPt{
|
||||||
topLeft.X -= 5 // Ensure we paint to every visible section of the screeen.
|
X: float64(s.Viewpoint.X - 2*cellWidth), // Ensure all visible cells are rendered
|
||||||
topLeft.X -= 5 // FIXME: haxxx
|
Y: float64(s.Viewpoint.Y - 2*cellHeight),
|
||||||
|
}.ToISO()
|
||||||
|
|
||||||
bottomRight := CartPt{X: float64(s.Viewpoint.X + sw), Y: float64(s.Viewpoint.Y + sh)}.ToISO()
|
bottomRight := CartPt{
|
||||||
bottomRight.X += 5
|
X: float64(s.Viewpoint.X + sw + 2*cellHeight),
|
||||||
bottomRight.Y += 5
|
Y: float64(s.Viewpoint.Y + sh + 5*cellHeight), // Z dimension requires it
|
||||||
|
}.ToISO()
|
||||||
|
|
||||||
// X+Y is constant for all tiles in a column
|
// X+Y is constant for all tiles in a column
|
||||||
// X-Y is constant for all tiles in a row
|
// X-Y is constant for all tiles in a row
|
||||||
|
@@ -1,10 +1,6 @@
|
|||||||
package scenario
|
package scenario
|
||||||
|
|
||||||
import (
|
import (
|
||||||
// "image"
|
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten"
|
|
||||||
|
|
||||||
"code.ur.gs/lupine/ordoor/internal/maps"
|
"code.ur.gs/lupine/ordoor/internal/maps"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -14,12 +10,6 @@ type CellPoint struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Scenario) CellAtCursor() (maps.Cell, CellPoint) {
|
func (s *Scenario) CellAtCursor() (maps.Cell, CellPoint) {
|
||||||
x, y := ebiten.CursorPosition()
|
cell := s.area.Cell(int(s.selectedCell.X), int(s.selectedCell.Y), 0)
|
||||||
screenPos := CartPt{X: float64(s.Viewpoint.X + x), Y: float64(s.Viewpoint.Y + y)}
|
return cell, CellPoint{IsoPt: s.selectedCell, Z: 0}
|
||||||
isoPos := screenPos.ToISO()
|
|
||||||
// Convert to cell coordinates.
|
|
||||||
// TODO: zoom support will need a camera
|
|
||||||
// FIXME: adjust for Z level
|
|
||||||
|
|
||||||
return s.area.Cell(int(isoPos.X), int(isoPos.Y), 0), CellPoint{IsoPt: isoPos, Z: s.ZIdx}
|
|
||||||
}
|
}
|
||||||
|
@@ -11,8 +11,9 @@ import (
|
|||||||
type Scenario struct {
|
type Scenario struct {
|
||||||
area *assetstore.Map
|
area *assetstore.Map
|
||||||
|
|
||||||
tick int
|
tick int
|
||||||
turn int
|
turn int
|
||||||
|
selectedCell IsoPt
|
||||||
|
|
||||||
// All these must be modified by user actions somehow.
|
// All these must be modified by user actions somehow.
|
||||||
// TODO: extract into the idea of a viewport passed to Update / Draw somehow?
|
// TODO: extract into the idea of a viewport passed to Update / Draw somehow?
|
||||||
|
Reference in New Issue
Block a user