Implement warping between maps
This commit is contained in:
parent
fdf69b8b11
commit
0323aeb924
BIN
8Bitsy.dsk
BIN
8Bitsy.dsk
Binary file not shown.
|
@ -1,6 +1,6 @@
|
|||
(local util (require :lib.util))
|
||||
(local actions (require :editor.actions))
|
||||
(local {: textbox : dropdown } (util.require :editor.imstate))
|
||||
(local {: textbox : dropdown : textfield} (util.require :editor.imstate))
|
||||
(local files (require :game.files))
|
||||
(local lume (require :lib.lume))
|
||||
(local style (require :core.style))
|
||||
|
@ -10,12 +10,11 @@
|
|||
(let [characters (lume.map files.game.portraits #$1.label)
|
||||
character (or action.character (. characters 1))
|
||||
lines (or action.lines [])
|
||||
(character y) (dropdown view [:say :char i] character characters x (+ y style.padding.y) 300)
|
||||
(line1 y) (textbox view [:say :line1 i] (. lines 1) x (+ y style.padding.y) 300)
|
||||
(line2 y) (textbox view [:say :line2 i] (. lines 2) x y 300)
|
||||
(line3 y) (textbox view [:say :line3 i] (. lines 3) x y 300)
|
||||
(line4 y) (textbox view [:say :line4 i] (. lines 4) x y 300)
|
||||
]
|
||||
(character y) (dropdown view [:say :char i] character characters x (+ y style.padding.y) w)
|
||||
(line1 y) (textbox view [:say :line1 i] (. lines 1) x (+ y style.padding.y) w)
|
||||
(line2 y) (textbox view [:say :line2 i] (. lines 2) x y w)
|
||||
(line3 y) (textbox view [:say :line3 i] (. lines 3) x y w)
|
||||
(line4 y) (textbox view [:say :line4 i] (. lines 4) x y w)]
|
||||
(set action.character character)
|
||||
(util.nested-tset action [:lines 1] line1)
|
||||
(util.nested-tset action [:lines 2] line2)
|
||||
|
@ -26,4 +25,18 @@
|
|||
(local {: say} (require :game.defs))
|
||||
(say action.character (table.unpack (lume.map action.lines #($1:upper))))))
|
||||
|
||||
(actions.register :warp
|
||||
(fn [action view x y w i]
|
||||
(let [maps (icollect [imap _ (ipairs files.game.levels)] (.. :map imap))
|
||||
map (or action.map (. maps 1))
|
||||
y (+ y style.padding.y)
|
||||
map (dropdown view [:warp :map i] map maps x y 100)
|
||||
(position-string y) (textbox view [:warp :loc i] (string.format "%x" (or action.position 0)) (+ x 150) y 150)
|
||||
position (or (tonumber position-string 16) action.position)]
|
||||
(set action.map map)
|
||||
(set action.position position)
|
||||
y))
|
||||
(fn [action vm]
|
||||
(values action.position :lit action.map :map-player-yx-ptr :set :lit action.map :next-level :set)))
|
||||
|
||||
{}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
(fn actions.register [key edit generate]
|
||||
(when (= actions.actionlist nil)
|
||||
(set actions.actionlist []))
|
||||
(lume.remove actions.actionlist key)
|
||||
(table.insert actions.actionlist key)
|
||||
(defmethod actions.edit key edit)
|
||||
(defmethod actions.generate key generate))
|
||||
|
|
|
@ -163,7 +163,7 @@
|
|||
(each [istep step (ipairs object.steps)]
|
||||
(when (textbutton self "X" (+ x 280) y)
|
||||
(set istep-to-delete istep))
|
||||
(set (step.action y) (dropdown self [:code-action istep] (or step.action :say) [:say :warp] x y 100))
|
||||
(set (step.action y) (dropdown self [:code-action istep] (or step.action (. actions.actionlist 1)) actions.actionlist x y 100))
|
||||
(set y (actions.edit step self x y 300 istep))
|
||||
(set y (+ y style.padding.y)))
|
||||
(when istep-to-delete (table.remove object.steps istep-to-delete))
|
||||
|
@ -198,7 +198,8 @@
|
|||
(set self.stripcache {})
|
||||
(when (= (. files.game.levels self.ilevel) nil)
|
||||
(tset files.game.levels self.ilevel {:map (string.rep "\0" (* mapw maph)) :objects []}))
|
||||
(set self.level (. files.game.levels self.ilevel)))
|
||||
(set self.level (. files.game.levels self.ilevel))
|
||||
(set self.iobject nil))
|
||||
|
||||
(fn MapEditView.reload [self]
|
||||
(MapEditView.super.reload self)
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
; TODO: Generate from data?
|
||||
(local {: vm : say : deflevel} (require :game.defs))
|
||||
|
||||
(deflevel 1 :map1)
|
|
@ -135,7 +135,8 @@
|
|||
(vm.code:append :map-ptr [:db 0] :map-page [:db 0])
|
||||
(vm:word :map :lit :map-ptr :get)
|
||||
(vm:word :entity-count :map 240 :+ :bget)
|
||||
(vm:word :map-player-yx :map 241 :+ :get)
|
||||
(vm:word :map-player-yx-ptr 241 :+)
|
||||
(vm:word :map-player-yx :map :map-player-yx-ptr :get)
|
||||
(vm:word :map-specific-tick :map 243 :+ :execute)
|
||||
(vm:word :map-specific-move :map 246 :+ :execute)
|
||||
(vm:word :map-specific-load :map 249 :+ :execute)
|
||||
|
@ -146,7 +147,7 @@
|
|||
(let [code []]
|
||||
(each [iaction action (ipairs (or entity.steps []))]
|
||||
(lume.push code (actions.generate action vm iaction)))
|
||||
(vm:word (.. prefix ientity) (table.unpack code))))))
|
||||
(vm:word (.. prefix ientity) :drop (table.unpack code))))))
|
||||
|
||||
(fn deflevel [ilevel label]
|
||||
(local level prg) ; todo: (asm.new prg) - if we want to load levels as an overlay
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,7 +1,7 @@
|
|||
(local util (require :lib.util))
|
||||
(local {: lo : hi : readjson} util)
|
||||
(local tile (util.reload :game.tiles))
|
||||
(local {: prg : vm : org} (util.reload :game.defs))
|
||||
(local {: prg : vm : org : deflevel} (util.reload :game.defs))
|
||||
(local files (require :game.files))
|
||||
|
||||
(local disk (util.reload :game.disk))
|
||||
|
@ -32,7 +32,8 @@
|
|||
:map-specific-load
|
||||
:full-redraw)
|
||||
|
||||
(util.reload :game.content)
|
||||
(each [imap _ (ipairs files.game.levels)]
|
||||
(deflevel imap (.. :map imap)))
|
||||
|
||||
(vm.code:append :main
|
||||
[:jsr :reset]
|
||||
|
|
Loading…
Reference in a new issue