feat(packages): ludic.minimap - a map's logic: the explored fog over a grid of cells round an origin (revealed within a reach, a version for rebaking, explored as a share of the land over a core square, the grid as text for an older save), the player's marks (a cap, a symbol, a colour, the day, a name; the open one and the followed one, rubbing out, the last symbol reused, the nearest for a compass) and the view (world to window and back, zoom in steps and about a point, a drag, pick and place, the camp, you, a focus that never pulls back out, a scale bar, bounds); the world through a port; seen and marks in its own save section by key
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fe9d28bf4e
commit
73a376ac6c
13 changed files with 830 additions and 0 deletions
53
packages/ludic.minimap/system.ludic
Normal file
53
packages/ludic.minimap/system.ludic
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# system.ludic - the map as a system: what has been seen and the marks, in its own save section by
|
||||
# key. The view is where the player left it this session and is not saved.
|
||||
export function minimap_reset() -> void {
|
||||
mm_grid()
|
||||
for c in 0 .. len(mm_seen) { mm_seen[c] = 0 }
|
||||
mm_version += 1
|
||||
minimap_pins_clear()
|
||||
mm_have_view = false
|
||||
mm_panning = false
|
||||
}
|
||||
|
||||
export function minimap_save() -> Val {
|
||||
let v = Value.object()
|
||||
sv_put_str(v, "seen", minimap_seen_text())
|
||||
let l = Value.list()
|
||||
for i in 0 .. minimap_pin_count() {
|
||||
let p = mm_pins[i]
|
||||
let o = Value.object()
|
||||
sv_put_float(o, "x", p.x)
|
||||
sv_put_float(o, "z", p.z)
|
||||
sv_put_int(o, "icon", p.icon)
|
||||
sv_put_int(o, "colour", p.colour)
|
||||
sv_put_int(o, "day", p.day)
|
||||
sv_put_str(o, "label", p.label)
|
||||
Value.add(l, o)
|
||||
}
|
||||
Value.put(v, "pins", l)
|
||||
sv_put_int(v, "followed", minimap_pin_followed())
|
||||
sv_put_int(v, "last", mm_last)
|
||||
return v
|
||||
}
|
||||
|
||||
export function minimap_load(v: Val, version: int) -> void {
|
||||
minimap_reset()
|
||||
minimap_seen_from_text(sv_str(v, "seen", ""))
|
||||
if Value.has(v, "pins") != 0 {
|
||||
let l = Value.get(v, "pins")
|
||||
for i in 0 .. Value.count(l) {
|
||||
let o = Value.at(l, i)
|
||||
minimap_pin_put(sv_float(o, "x", 0.0), sv_float(o, "z", 0.0), sv_int(o, "icon", 0), sv_int(o, "colour", 0), sv_int(o, "day", 1), sv_str(o, "label", ""))
|
||||
}
|
||||
}
|
||||
minimap_pin_follow(sv_int(v, "followed", -1))
|
||||
mm_last = Math.clamp(sv_int(v, "last", 0), 0, mm_symbols - 1)
|
||||
}
|
||||
|
||||
export function minimap_system() -> System {
|
||||
let s = system_new("minimap", PH_COMMIT)
|
||||
s.reset = fn minimap_reset
|
||||
s.save = fn minimap_save
|
||||
s.load = fn minimap_load
|
||||
return s
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue