From a4e7629ee2cfdff702568358f99c64d61c53e649 Mon Sep 17 00:00:00 2001 From: Jeremy Penner Date: Wed, 16 Dec 2020 22:59:55 -0500 Subject: [PATCH] Implement garbage-dropping rexx --- editor/mapedit.fnl | 4 +++- game/init.fnl | 22 +++++++++++++++------- game/level5.fnl | 32 ++++++++++++++++++++++++++++++++ game/map5.json | 2 +- game/tiles.fnl | 3 ++- game/tiles.json | 2 +- 6 files changed, 54 insertions(+), 11 deletions(-) diff --git a/editor/mapedit.fnl b/editor/mapedit.fnl index 3ebc3fb..45661e2 100644 --- a/editor/mapedit.fnl +++ b/editor/mapedit.fnl @@ -183,6 +183,8 @@ (set y (+ y (* tileh maph) 10)) (set self.level.tickword (textfield self "Tick word" self.level.tickword x y 100 200)) (set y (+ y 30)) + (set self.level.moveword (textfield self "Move word" self.level.moveword x y 100 200)) + (set y (+ y 30)) (when (checkbox self "Edit objects" (= self.itile nil) x y) (set self.itile nil) (set self.playerpos nil)) @@ -192,7 +194,7 @@ (set self.itile nil) (set self.playerpos player)) (set y (+ y 30))) - (when (checkbox self "Is Gord following?" self.level.gord-following x y) + (when (checkbox self "Start with Gord" self.level.gord-following x y) (set self.level.gord-following (not self.level.gord-following))) (set y (+ y 30)) (self:draw-tile-selector x y (- self.size.x 20))) diff --git a/game/init.fnl b/game/init.fnl index 08ac83d..fcb35e5 100644 --- a/game/init.fnl +++ b/game/init.fnl @@ -82,14 +82,22 @@ :gord-sitting :set :move-player-to controlstate.jaye :controlstate :bset) +(vm:word :move-rexx-trash ; yx -- f + (vm:if-and [[:dup debris :flag-at?] [:is-rexx?]] + [(itile :t-floor) :update-itile] [:drop]) + vm.false) +(vm:word :move-gord-sit ; yx -- f + (vm:if-and [[:dup sittable :flag-at?] [:is-jaye?] [:gord-following?]] + [vm.true :transition-gord-sitting vm.true] + [:move-noop])) +(vm:word :move-gord-stand ; yx -- f + (vm:if-and [[:gord-yx :get :=] [:is-jaye?] [:gord-sitting :get]] + [:jaye-yx :get vm.false :transition-gord-sitting 0 :gord-dir :set vm.true] + [vm.false])) +(vm:word :move-noop :drop vm.false) (vm:word :handle-special-move ; yx -- f - (vm:if-and [[:is-rexx?] [:dup debris :flag-at?]] - [(itile :t-floor) :update-itile vm.false] - [(vm:if-and [[:is-jaye?] [:gord-following?] [:dup sittable :flag-at?]] - [vm.true :transition-gord-sitting vm.true] - [(vm:if-and [[:is-jaye?] [:gord-sitting :get] [:dup :gord-yx :get :=]] - [:drop :jaye-yx :get vm.false :transition-gord-sitting 0 :gord-dir :set vm.true] - [:drop vm.false])])])) + (vm:if-or [[:dup :map-specific-move] [:dup :move-rexx-trash] [:dup :move-gord-sit] [:dup :move-gord-stand]] + [:drop vm.true] [:move-noop])) (vm:def :yxclip? ; yx -- f [:block diff --git a/game/level5.fnl b/game/level5.fnl index 18c2b1f..920f4f7 100644 --- a/game/level5.fnl +++ b/game/level5.fnl @@ -1,5 +1,7 @@ (local {: deflevel : say : itile} (require :game.defs)) (local {: ev} (require :game.entity)) +(local tile (require :game.tiles)) +(local {: walkable : neutable : debris : sittable} tile.flag-to-bit) (local level (deflevel "game/map5.json")) (local vm level.vm) @@ -15,4 +17,34 @@ ; only gord is physically able to touch it :dup ev.touch := (vm:when :start-doortimer :drop ev.act) :switch) +(vm:var :is-garbagerexx vm.false) +(vm:var :garbagerexx-yx 0x0710) +; shit, rexx doesn't live in an object - I can't tag by word :/ +(vm:word :garbagerexx ; ev -- + :is-rexx? :swap :rexx :is-rexx? := :not (vm:when + :is-rexx? (vm:if [ + :garbagerexx-yx :get :get-responder :get := (vm:when + vm.true :is-garbagerexx :set) + ] [ + :is-garbagerexx :get (vm:when + :get-responder :get :garbagerexx-yx :set + vm.false :is-garbagerexx :set) + ]))) + +(vm:word :not-picking-up? ; yxdest -- f + debris :flag-at? :not) +(vm:word :can-drop-rubble? ; yxdest -- f + :itile-at (itile :t-floor) := + :rexx-yx :get :itile-at (itile :t-floor) := :&) + +(vm:word :move-garbagerexx ; yx -- f + (vm:if-and [[:is-rexx?] [:is-garbagerexx :get]] + [:dup 0xff :& 0x0d := (vm:if [ + (say :rexx "PARITY ERROR!") :drop vm.true :ret + ] [ + (vm:if-and [[:dup :not-picking-up?] [:dup :can-drop-rubble?]] + [:rexx-yx :get (itile :broken-table) :update-itile]) + ])]) + :move-noop) + level diff --git a/game/map5.json b/game/map5.json index 5cc5693..5f66857 100644 --- a/game/map5.json +++ b/game/map5.json @@ -1 +1 @@ -{"neut":{"y":6,"x":20},"map":"21616161228161616161616161616161616162612102E0C0C0C0C0E0C04361C0C0C0C0C0A3C0C0612161C0C0C0C0C0C0C0C022C0C0C08282C0828261416103C0C0C0C0C0C0C081C0C0C0C0C0C0C0C2C1210203C0C0C0C0C0C04361C0C0C08282838282622161616161816161616161618161616161616161216163C0C0C0C0E0C0C06143C0C0C0C0C0C063612102C0C0C0C0C0C0C0C061C0C0C0C0C0C0C0C0814161C0C0C0C0E2C0E2836101C0C0C0C0C0C0C0C1216143C0C0C082A2A2A281C0C0C043034382E26121610261610261C16102616161026161610261612121212121214121212121212121214121212121","jaye":{"y":5,"x":19},"tickword":"doortimer-tick","gord-following":true,"objects":[{"x":17,"func":"rexx","y":11,"linkword":"","name":""},{"x":17,"func":"rexx","y":8,"linkword":"","name":""},{"link":13,"y":9,"func":"do-timedswitch","name":"timedswitch","linkword":"","x":20},{"link":16,"y":4,"func":"switch","name":"","linkword":"","x":20},{"link":9,"y":4,"func":"term","name":"","linkword":"","x":12},{"x":10,"func":"rexx","y":4,"linkword":"","name":""},{"link":17,"y":2,"func":"switch","name":"","linkword":"","x":8},{"link":10,"y":6,"func":"term","name":"","linkword":"","x":8},{"link":5,"y":11,"func":"term","name":"","linkword":"","x":8},{"link":8,"y":11,"func":"term","name":"","linkword":"","x":3},{"link":12,"y":12,"func":"scan","name":"","linkword":"","x":5},{"x":6,"func":"door","y":12,"linkword":"","name":""},{"x":6,"func":"door","y":7,"linkword":"","name":""},{"x":11,"func":"door","y":9,"linkword":"","name":""},{"link":14,"y":10,"func":"scan","name":"","linkword":"","x":11},{"x":13,"func":"door","y":7,"linkword":"","name":""},{"x":11,"func":"door","y":3,"linkword":"","name":""}]} \ No newline at end of file +{"neut":{"y":6,"x":20},"map":"21616161228161616161616161616161616162612102E0C0C0C0C0E0C04361C0C0C0C0C0A3C0C0612161C0C0C0C0C0C0C0C022C0C0C08282C0828261416103C0C0C0C0C0C0C081C0C0C0C0C0C0C0C2C1210203C0C0C0C0C0C04361C0C0C08282838282622161616161816161616161618161616161616161216163C0C0C0C0E0C0C06143C0C0C0C0C0C063612102C0C0C0C0C0C0C0C061C0C0C0C0C0C0C0C0814161C0C0C0C0E2C0E2836101C0C0C0C0C0C0C0C1216143C0C0C082A2A2A281C0C0C043034382E26121610261610261C16102616161026161610261612121212121214121212121212121214121212121","tickword":"doortimer-tick","jaye":{"y":5,"x":19},"gord-following":true,"moveword":"move-garbagerexx","objects":[{"x":17,"func":"garbagerexx","y":11,"name":"","linkword":""},{"x":17,"func":"garbagerexx","y":8,"name":"","linkword":""},{"x":20,"func":"do-timedswitch","y":9,"name":"timedswitch","linkword":"","link":13},{"x":20,"func":"switch","y":4,"name":"","linkword":"","link":16},{"x":12,"func":"term","y":4,"name":"","linkword":"","link":9},{"x":10,"func":"garbagerexx","y":4,"name":"","linkword":""},{"x":8,"func":"switch","y":2,"name":"","linkword":"","link":17},{"x":8,"func":"term","y":6,"name":"","linkword":"","link":10},{"x":8,"func":"term","y":11,"name":"","linkword":"","link":5},{"x":3,"func":"term","y":11,"name":"","linkword":"","link":8},{"x":5,"func":"scan","y":12,"name":"","linkword":"","link":12},{"x":6,"func":"door","y":12,"name":"","linkword":""},{"x":6,"func":"door","y":7,"name":"","linkword":""},{"x":11,"func":"door","y":9,"name":"","linkword":""},{"x":11,"func":"scan","y":10,"name":"","linkword":"","link":14},{"x":13,"func":"door","y":7,"name":"","linkword":""},{"x":11,"func":"door","y":3,"name":"","linkword":""}]} \ No newline at end of file diff --git a/game/tiles.fnl b/game/tiles.fnl index 282c2a5..addba86 100644 --- a/game/tiles.fnl +++ b/game/tiles.fnl @@ -47,7 +47,8 @@ :map-jaye-yx [:dw (encode-yx map.jaye)] :map-neut-yx [:dw (encode-yx map.neut)] :map-gord-yx [:dw (if map.gord-following (encode-yx map.jaye) 0xffff)] - :map-specific-tick [:jmp (if (= (or map.tickword "") "") :next map.tickword)])) + :map-specific-tick [:jmp (if (= (or map.tickword "") "") :next map.tickword)] + :map-specific-move [:jmp (if (= (or map.moveword "") "") :move-noop map.moveword)])) (fn find-itile [tiles label ?itilenext] (local itile (or ?itilenext 1)) diff --git a/game/tiles.json b/game/tiles.json index 2bc4186..26110ca 100644 --- a/game/tiles.json +++ b/game/tiles.json @@ -1 +1 @@ -[{"gfx":"7F7F1F03090923436943230909031F7F7F7F784111104542174245101141787F","word":"","label":"neut1","flags":[]},{"gfx":"7F1F03090923436943230909031F7F7F7F784111104542174245101141787F7F","word":"","label":"neut2","flags":[]},{"gfx":"808080C0C0C0E0C0D0C8C04040404080808083058585828A9282820A08081980","word":"","label":"jaye-e","flags":[]},{"gfx":"8080C020A0A0C0C0D0C8C0501010188080808183838782828A8A920202020380","word":"","label":"jaye-w","flags":[]},{"gfx":"8080E030B0B098C0D0D0C840404060808080870D8D8D99828A8A920202020780","word":"","label":"jaye-s","flags":[]},{"gfx":"8080C0E0E0E0B0C0D0C8C040404060808080838787878D828A92820202020780","word":"","label":"jaye-n","flags":[]},{"gfx":"80808C8080808080B08080808C808080808C80808083B0808080808080868080","word":"","label":"t-floor","flags":{"walkable":true}},{"gfx":"007C0C0C0C0C7C007C7E7EAA88888800001F181818181F001F0F979584848400","word":"term","label":"termoff","flags":[]},{"gfx":"007C2C0C0C2C7C007C7E7EAA88888800001F18191C191F001F0F979584848400","word":"term","label":"termon","flags":{"neutable":true}},{"gfx":"D5D5D5D5D5D5D5D5D5D5D5D5D5D5D5D5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA","word":"","label":"","flags":[]},{"gfx":"D5D5D5D5D5F5F5FDDDD5D5D5D5D5D5D5AAAAAAAAAEAEBFBFBFABAAAAAAAAAAAA","word":"","label":"","flags":[]},{"gfx":"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","word":"","label":"","flags":{"neutable":true}},{"gfx":"FF8FA7B3B3B3B3B3B3B3B3B3B3B383FFFFF8F2E6E6E6E6E6E6E6E6E6E6E6E0FF","word":"door","label":"doorclosed","flags":[]},{"gfx":"FF8F87838383838383838383838383FFFFF8F0E0E0E0E0E0E0E0E0E0E0E0E0FF","word":"door","label":"dooropen","flags":{"walkable":true}},{"gfx":"FFFFCFCFCFCF898183838787878FFFFFFFFCE4E4E4E4E0E0E0E0E0E0F0F8FFFF","word":"switch","label":"switchoff","flags":{"neutable":true}},{"gfx":"FFFFCFCFCFCF898123232727878FFFFFFFFCE4E4E4E0E0616565656571F8FFFF","word":"switch","label":"switchon","flags":{"neutable":true}},{"gfx":"FFFF83D3D3D3D3D3D3D3D3D3D383FFFFFFFFC0CACACECACBCACACACACAC0FFFF","word":"","label":"","flags":[]},{"gfx":"FFFFAFEBFBFBFBBBBBFBFBFBEBAFFFFFFFFFF5D7DFDFDFDDDDDFDFDFD7F5FFFF","word":"scan","label":"scanoff","flags":{"neutable":true}},{"gfx":"FFFF2F2B2B2B6B6B6B6B2B2B2B2FFFFFFFFF755555555757575755555575FFFF","word":"scan","label":"scanon","flags":{"neutable":true}},{"gfx":"FFF3C78FBFFCF98187BFFFFFBF9F9FC7FFCFE1F1FCFCF8FEFEFCF9F0E6CE8F9F","word":"","label":"","flags":[]},{"gfx":"80808C80808080A8AAAAAAA888888880808C8080808380859595958584848480","word":"","label":"","flags":[]},{"gfx":"80808C8080A0A0A8AAAA8AA0A8808080808C8081919090848594959585858080","word":"","label":"","flags":{"debris":true}},{"gfx":"00005054545450404054545010383800000C0A2A2A2A0A03032A2A0A081C1C00","word":"","label":"t-chair","flags":{"sittable":true}},{"gfx":"0000001C1C10545040606010545454000030070702020A0A0100020A080A0200","word":"","label":"","flags":{"debris":true}},{"gfx":"80A0A8AA92D2D2AAC2C2AA92D2AA808080959595949494959494959494858080","word":"","label":"","flags":[]},{"gfx":"80808C808080A8C292AAAAAAAA8AC0D0808C80808083959290959194948580A8","word":"","label":"","flags":{"debris":true}},{"gfx":"80806008282A0800202880A8A8A8A08080980000141501051511819595958580","word":"","label":"","flags":[]},{"gfx":"80808C808080A0A8AAAA8AA2AAAAAA80808C0000000330010105051511010514","word":"","label":"","flags":{"debris":true}},{"gfx":"80D0D0D0C0D4C4C4CECAC0E0A0808080808A8B8A82AAA2A2F2D2828785808080","word":"rexx","label":"t-rexx","flags":[]},{"gfx":"F8989898BE8686868686BEB098F880809F989898FCE0E0E0E0E0FC8C989F8080","word":"rexx","label":"t-rexxstop","flags":[]},{"gfx":"80808C8088A8A8E0E0F0C8C0CCC08080808C80808080B08183838282829A8080","word":"","label":"gord-ground","flags":[]},{"gfx":"808080A0A080F0F0F0E8D0D09098808080808081818083838385828282868080","word":"","label":"gord-s","flags":[]},{"gfx":"80C09090A080F0F0F0F0D0D09098808080808282818083838383828282868080","word":"","label":"gord-n","flags":[]},{"gfx":"808080A0A080F0F0F0F0D0D090B0808080808181818081838581808282868080","word":"","label":"gord-e","flags":[]},{"gfx":"8080A0A0A080E0F0E8E0D0D09098808080808081818083838383828282838080","word":"","label":"gord-w","flags":[]},{"gfx":"0088A8A8047470F8B8D4D4C4C4E40600000C0A2A2A2A0A81812A2A0A081C1C00","word":"","label":"gord-sit","flags":[]}] \ No newline at end of file +[{"gfx":"7F7F1F03090923436943230909031F7F7F7F784111104542174245101141787F","word":"","label":"neut1","flags":[]},{"gfx":"7F1F03090923436943230909031F7F7F7F784111104542174245101141787F7F","word":"","label":"neut2","flags":[]},{"gfx":"808080C0C0C0E0C0D0C8C04040404080808083058585828A9282820A08081980","word":"","label":"jaye-e","flags":[]},{"gfx":"8080C020A0A0C0C0D0C8C0501010188080808183838782828A8A920202020380","word":"","label":"jaye-w","flags":[]},{"gfx":"8080E030B0B098C0D0D0C840404060808080870D8D8D99828A8A920202020780","word":"","label":"jaye-s","flags":[]},{"gfx":"8080C0E0E0E0B0C0D0C8C040404060808080838787878D828A92820202020780","word":"","label":"jaye-n","flags":[]},{"gfx":"80808C8080808080B08080808C808080808C80808083B0808080808080868080","word":"","label":"t-floor","flags":{"walkable":true}},{"gfx":"007C0C0C0C0C7C007C7E7EAA88888800001F181818181F001F0F979584848400","word":"term","label":"termoff","flags":[]},{"gfx":"007C2C0C0C2C7C007C7E7EAA88888800001F18191C191F001F0F979584848400","word":"term","label":"termon","flags":{"neutable":true}},{"gfx":"D5D5D5D5D5D5D5D5D5D5D5D5D5D5D5D5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA","word":"","label":"","flags":[]},{"gfx":"D5D5D5D5D5F5F5FDDDD5D5D5D5D5D5D5AAAAAAAAAEAEBFBFBFABAAAAAAAAAAAA","word":"","label":"","flags":[]},{"gfx":"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","word":"","label":"","flags":{"neutable":true}},{"gfx":"FF8FA7B3B3B3B3B3B3B3B3B3B3B383FFFFF8F2E6E6E6E6E6E6E6E6E6E6E6E0FF","word":"door","label":"doorclosed","flags":[]},{"gfx":"FF8F87838383838383838383838383FFFFF8F0E0E0E0E0E0E0E0E0E0E0E0E0FF","word":"door","label":"dooropen","flags":{"walkable":true}},{"gfx":"FFFFCFCFCFCF898183838787878FFFFFFFFCE4E4E4E4E0E0E0E0E0E0F0F8FFFF","word":"switch","label":"switchoff","flags":{"neutable":true}},{"gfx":"FFFFCFCFCFCF898123232727878FFFFFFFFCE4E4E4E0E0616565656571F8FFFF","word":"switch","label":"switchon","flags":{"neutable":true}},{"gfx":"FFFF83D3D3D3D3D3D3D3D3D3D383FFFFFFFFC0CACACECACBCACACACACAC0FFFF","word":"","label":"","flags":[]},{"gfx":"FFFFAFEBFBFBFBBBBBFBFBFBEBAFFFFFFFFFF5D7DFDFDFDDDDDFDFDFD7F5FFFF","word":"scan","label":"scanoff","flags":{"neutable":true}},{"gfx":"FFFF2F2B2B2B6B6B6B6B2B2B2B2FFFFFFFFF755555555757575755555575FFFF","word":"scan","label":"scanon","flags":{"neutable":true}},{"gfx":"FFF3C78FBFFCF98187BFFFFFBF9F9FC7FFCFE1F1FCFCF8FEFEFCF9F0E6CE8F9F","word":"","label":"","flags":[]},{"gfx":"80808C80808080A8AAAAAAA888888880808C8080808380859595958584848480","word":"","label":"","flags":[]},{"gfx":"80808C8080A0A0A8AAAA8AA0A8808080808C8081919090848594959585858080","word":"","label":"broken-table","flags":{"debris":true}},{"gfx":"00005054545450404054545010383800000C0A2A2A2A0A03032A2A0A081C1C00","word":"","label":"t-chair","flags":{"sittable":true}},{"gfx":"0000001C1C10545040606010545454000030070702020A0A0100020A080A0200","word":"","label":"","flags":{"debris":true}},{"gfx":"80A0A8AA92D2D2AAC2C2AA92D2AA808080959595949494959494959494858080","word":"","label":"","flags":[]},{"gfx":"80808C808080A8C292AAAAAAAA8AC0D0808C80808083959290959194948580A8","word":"","label":"","flags":{"debris":true}},{"gfx":"80806008282A0800202880A8A8A8A08080980000141501051511819595958580","word":"","label":"","flags":[]},{"gfx":"80808C808080A0A8AAAA8AA2AAAAAA80808C0000000330010105051511010514","word":"","label":"","flags":{"debris":true}},{"gfx":"80D0D0D0C0D4C4C4CECAC0E0A0808080808A8B8A82AAA2A2F2D2828785808080","word":"rexx","label":"t-rexx","flags":[]},{"gfx":"F8989898BE8686868686BEB098F880809F989898FCE0E0E0E0E0FC8C989F8080","word":"rexx","label":"t-rexxstop","flags":[]},{"gfx":"80808C8088A8A8E0E0F0C8C0CCC08080808C80808080B08183838282829A8080","word":"","label":"gord-ground","flags":[]},{"gfx":"808080A0A080F0F0F0E8D0D09098808080808081818083838385828282868080","word":"","label":"gord-s","flags":[]},{"gfx":"80C09090A080F0F0F0F0D0D09098808080808282818083838383828282868080","word":"","label":"gord-n","flags":[]},{"gfx":"808080A0A080F0F0F0F0D0D090B0808080808181818081838581808282868080","word":"","label":"gord-e","flags":[]},{"gfx":"8080A0A0A080E0F0E8E0D0D09098808080808081818083838383828282838080","word":"","label":"gord-w","flags":[]},{"gfx":"0088A8A8047470F8B8D4D4C4C4E40600000C0A2A2A2A0A81812A2A0A081C1C00","word":"","label":"gord-sit","flags":[]}] \ No newline at end of file