Drag flow into view-map

This is pretty awful, but will let me wire up items more easily without
needing to do the big refactor into independent menu handlers
This commit is contained in:
2020-06-13 16:37:39 +01:00
parent 7677c30572
commit 3b7cfb6ecc
5 changed files with 65 additions and 29 deletions

View File

@@ -102,18 +102,27 @@ func (m *Map) SpritesForCell(x, y, z int) ([]*Sprite, error) {
sprites = append(sprites, sprite)
}
for _, chr := range m.raw.Characters {
if chr.XPos == x && chr.YPos == y && z == 1 { // FIXME: sort out ZPos
// Look up the correct animation, get the frame, boom
anim, err := m.assets.CharacterAnimation(chr.Type, data.AnimActionNone)
if err != nil {
return nil, err
}
sprites = append(sprites, anim.Frames[0])
if chr := m.CharacterAt(x, y, z); chr != nil {
// Look up the correct animation, get the frame, boom
anim, err := m.assets.CharacterAnimation(chr.Type, data.AnimActionNone)
if err != nil {
return nil, err
}
sprites = append(sprites, anim.Frames[0])
}
return sprites, nil
}
func (m *Map) CharacterAt(x, y, z int) *maps.Character {
// FIXME: don't iterate
for i, _ := range m.raw.Characters {
chr := &m.raw.Characters[i]
if chr.XPos == x && chr.YPos == y && z == 1 { // FIXME: sort out ZPos
return chr
}
}
return nil
}

View File

@@ -92,6 +92,11 @@ func New(assets *assetstore.AssetStore, config *config.Config, ship *ship.Ship)
return out, out.exit
}
func (f *Flow) SetScenario(scenario *scenario.Scenario) {
f.current = f.drivers[mainGame]
f.scenario = scenario
}
func (f *Flow) Update(screenX, screenY int) error {
if f.exit != nil {
return f.exit

View File

@@ -16,7 +16,7 @@ func (f *Flow) linkMainGame() {
})
// 8: Character stats
f.onClick(mainGame, "8.21", func() { // Stat more buttont
f.onClick(mainGame, "8.21", func() { // Stat more buttons
f.setActiveNow(mainGame, "7", true)
f.setActiveNow(mainGame, "8", false)
})

View File

@@ -2,7 +2,6 @@
package scenario
import (
"fmt"
"image"
"code.ur.gs/lupine/ordoor/internal/assetstore"
@@ -36,9 +35,9 @@ func NewScenario(assets *assetstore.AssetStore, name string) (*Scenario, error)
}
// 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)
}
//if err := area.LoadSprites(); err != nil {
// return nil, fmt.Errorf("Eager-loading sprites failed: %v", err)
//}
out := &Scenario{
area: area,