This is pretty awful, but will let me wire up items more easily without needing to do the big refactor into independent menu handlers
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
// package play takes a map and turns it into a playable scenario
|
|
package scenario
|
|
|
|
import (
|
|
"image"
|
|
|
|
"code.ur.gs/lupine/ordoor/internal/assetstore"
|
|
)
|
|
|
|
type Scenario struct {
|
|
area *assetstore.Map
|
|
specials *assetstore.Object
|
|
|
|
tick int
|
|
turn int
|
|
selectedCell IsoPt
|
|
|
|
// All these must be modified by user actions somehow.
|
|
// TODO: extract into the idea of a viewport passed to Update / Draw somehow?
|
|
// Or have a separater Drawer for the Scenario?
|
|
Viewpoint image.Point // Top-left of the screen
|
|
ZIdx int // Currently-viewed Z index
|
|
Zoom float64 // Zoom level to set
|
|
}
|
|
|
|
func NewScenario(assets *assetstore.AssetStore, name string) (*Scenario, error) {
|
|
area, err := assets.Map(name)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
specials, err := assets.Object("specials") // FIXME: should this be hardcoded?
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
// Eager load sprites. TODO: do we really want to do this?
|
|
//if err := area.LoadSprites(); err != nil {
|
|
// return nil, fmt.Errorf("Eager-loading sprites failed: %v", err)
|
|
//}
|
|
|
|
out := &Scenario{
|
|
area: area,
|
|
specials: specials,
|
|
Viewpoint: image.Pt(0, 3000), // FIXME: haxxx
|
|
Zoom: 1.0,
|
|
}
|
|
|
|
return out, nil
|
|
}
|