Integrate view-map into ordoor
Now we can view scenario maps from the main game interface. We can't cancel out of a scenario yet, though.
This commit is contained in:
41
internal/scenario/scenario.go
Normal file
41
internal/scenario/scenario.go
Normal file
@@ -0,0 +1,41 @@
|
||||
// package play takes a map and turns it into a playable scenario
|
||||
package scenario
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image"
|
||||
|
||||
"code.ur.gs/lupine/ordoor/internal/assetstore"
|
||||
)
|
||||
|
||||
type Scenario struct {
|
||||
area *assetstore.Map
|
||||
|
||||
tick int
|
||||
turn int
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
func NewScenario(assets *assetstore.AssetStore, name string) (*Scenario, error) {
|
||||
area, err := assets.Map(name)
|
||||
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,
|
||||
Viewpoint: image.Pt(0, 3000), // FIXME: haxxx
|
||||
}
|
||||
|
||||
return out, nil
|
||||
}
|
Reference in New Issue
Block a user