From 51c5b9c6b77c1dae254f9930e4b0cc3a798137c0 Mon Sep 17 00:00:00 2001 From: Jeremy Penner Date: Wed, 10 Feb 2021 23:26:08 -0500 Subject: [PATCH] Implement level 1 introduction --- NeutTower.dsk | Bin 143360 -> 143360 bytes editor/mapedit.fnl | 11 +++-------- game/level1.fnl | 33 ++++++++++++++++++++++++++++++++- game/map1.json | 2 +- game/tiles.fnl | 11 +++++++++-- 5 files changed, 45 insertions(+), 12 deletions(-) diff --git a/NeutTower.dsk b/NeutTower.dsk index 16038a0e687fd58bd9068ebb5c7970f47d7d9476..127f963eaeb23addd9f4377ddbbfd96bfbc3b6f8 100644 GIT binary patch delta 6169 zcmZ8l3tUuH8ozg5%)mXvKvrt~TGSqv_Ok0nW-c@M0HsX9A8MNND;_$HBBBirc=5_h z@YP%fPy~CcS%ywEJ+_}CwT7#u+t#LQB}uiemDX-$tq=D5zB4ly(4X9MzVrY7-{XAe zI|nPft(D!@jxwvbAh^nUb&j||+dS`jv0Zy*UZ?ZM1$RAC`ote)_Fc(h%emwazFlt* zy!h;fnmj3IRK?C6_ulDx+S&RPu{S+a9CAgjQ?O94tE-y^rdlF zJpc>cD&RUfF05)x_6`+0wRL;18;eTe&TyE>j0oz48UMpc@|<}_V>mq`MVV1MvG*oJ zN&dcl@l1KEP!JsXj=22=f?&;;;y#=#2&ws2VP}ybjLf$Qp2^n9!eX--yOIxI z!Dca9Og59nXf%lqQ8Xl3MO*H4XT~rgC&QVOlIzS)aXyqX$vHD8W5z7!v`NE+l#x=; z44I|n%Pd})&dOMT{XPG2R&cw0I%{^Eu*`?wum&}AmTb(k?$8c29v;wO>=l7wRhG3wyHy?D|3-d~X5zATv>TBkNYyIT^`u zgb4I;#ByB6Sta>=FU(~&b$L!yx&TqxBy|svu0mb2E5xRj2B&sT7nM@olc}Ylk_%EQ zWMpb72u;PB(2rD7D+df^o3>Dqsb6^m3u==ZxBI< zyu8P@Z4pB3 zNU?V0;4-CHuYn`Q9uJT5NHIp~@${{MY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$4>U6$j;X*_0xfv|P{3;l VeU>EN+AQC7`R&TSXZtj_{~yA2HwXX# diff --git a/editor/mapedit.fnl b/editor/mapedit.fnl index 7ba088a..aa2f64e 100644 --- a/editor/mapedit.fnl +++ b/editor/mapedit.fnl @@ -4,7 +4,7 @@ (local lume (require :lib.lume)) (local {: mouse-inside : activate : active? : checkbox : textfield : textbutton} (util.require :editor.imstate)) (local {: tilestrip-to-sprite} (util.require :editor.tiledraw)) -(local {: encode-yx} (util.require :game.tiles)) +(local {: encode-yx : encode-itile : decode-itile} (util.require :game.tiles)) (local MapEditView (GraphicsEditView:extend)) (local sprite-scale 3) @@ -26,10 +26,7 @@ (fn update-map [map mx my itile] (local imap (imap-from-xy mx my)) - (local enctile - (bit.bor - (bit.lshift (bit.band (- itile 1) 0x07) 5) - (bit.rshift (bit.band (- itile 1) 0xf8) 3))) + (local enctile (encode-itile itile)) (.. (map:sub 1 imap) (string.char enctile) @@ -38,9 +35,7 @@ (fn MapEditView.itile-from-xy [self mx my] (local imap (+ (imap-from-xy mx my) 1)) (local enctile (string.byte (self.level.map:sub imap imap))) - (+ 1 (bit.bor - (bit.lshift (bit.band enctile 0x1f) 3) - (bit.rshift (bit.band enctile 0xe0) 5)))) + (decode-itile enctile)) (fn MapEditView.set-tile [self mx my itile] (set self.level.map (update-map self.level.map mx my itile))) diff --git a/game/level1.fnl b/game/level1.fnl index df38061..9f078fa 100644 --- a/game/level1.fnl +++ b/game/level1.fnl @@ -1,8 +1,39 @@ -(local {: deflevel : say : itile : controlstate} (require :game.defs)) +(local {: readjson} (require :lib.util)) +(local {: deflevel : say : itile : controlstate : tilelist} (require :game.defs)) (local {: ev} (require :game.entity)) +(local {: decode-itile : encode-yx} (require :game.tiles)) (local level (deflevel "game/map1.json" :level1)) (local vm level.vm) +(let [map (readjson "game/map1.json") + maptiles (map.map:fromhex) + furniture-yx []] + (for [ibyte 1 (length maptiles)] + (let [btile (maptiles:sub ibyte ibyte) + enctile (string.byte btile) + itile (+ (decode-itile enctile) 1) + mx (+ (% (- ibyte 1) 20) 1) + my (- 12 (math.floor (/ (- ibyte 1) 20)))] + (when (. tilelist itile :flags :debris) + (print mx my itile) + (table.insert furniture-yx (encode-yx {:x mx :y my}))))) + (vm.code:append :furniture-yx) + (for [_ 1 10] + (let [ifurniture (math.random 1 (length furniture-yx))] + (vm.code:append [:dw (. furniture-yx ifurniture)]) + (table.remove furniture-yx ifurniture)))) + +(vm:word :earthquake ; -- + :full-redraw + :lit :furniture-yx + 10 (vm:for :rnd :shl4 0x7ff :& :snooze + :dup :get :dup :itile-at 0x20 :+ :update-itile + :snd-explode + (vm:i) 9 := (vm:when (say :jaye "WOAH!") :hide-footer) + 2 :+) :drop + 0x1000 :snooze + (say :jaye "THAT WAS AN EARTHQUAKE!")) + (vm:word :firstdoor (vm:if-and [[:is-jaye?] [:dup ev.touch :=] [:responder-itile (itile :doorclosed) :=]] [ (say :jaye "IT WON'T OPEN!") diff --git a/game/map1.json b/game/map1.json index 0cb6759..6fd524e 100644 --- a/game/map1.json +++ b/game/map1.json @@ -1 +1 @@ -{"loadword":"","map":"212121214121212121212121212141212121212161026161610261616102616161616102616161216143C0C0E2C0C0C0C0C0C0C081C0C0C0C0C0612161C0C0A282C0C0C0A2C0C0C061C0C0C0C0C2024161C0C0C0C0C0C0C0C0C2C0A2C1A2C0C0E082612161E2C08282C0C0C0C0A2C0C061616161616161216161616161C16181616161616143C0C0E282612161C0C0C0C0C0C0C0C0C0C0C061C0C0C0C0C0022161E08282A2C0C0C0C0E2C0C081C0C0C0C003612161E2C2C2C0C0C0C0C0C0C0C061C0C0C0C0C06141610303C063E2C0C0C0C0C0C061C0C0C023C061216161616161616161228161616161616161610221","jaye":{"y":9,"x":15},"tickword":"","moveword":"","objects":[{"x":8,"func":"door","name":"","linkword":"","y":6},{"link":3,"y":4,"func":"firstterm","name":"","linkword":"","x":2},{"link":2,"y":8,"func":"neutterm","name":"","linkword":"","x":17},{"link":8,"y":8,"func":"switch","name":"","linkword":"","x":13},{"x":9,"link":6,"func":"exitscanner","linkword":"","name":"","y":1},{"x":10,"linkentity":"level2","func":"exitdoor","y":1,"linkword":"exitlevel","name":""},{"x":6,"link":1,"func":"switch","linkword":"","name":"","y":6},{"x":13,"func":"firstdoor","linkword":"","name":"","y":10}]} \ No newline at end of file +{"loadword":"earthquake","map":"212121214121212121212121212141212121212161026161610261616102616161616102616161216143C0C0C2C0C0C0C0C0C0C081C0C0C0C0C0612161C0C08282C0C0C082C0C0C061C0C0C0C0C2024161C0C0C0C0C0C0C0C0C2C082C182C0C0E082612161C2C08282C0C0C0C082C0C061616161616161216161616161C16181616161616143C0C0C282612161C0C0C0C0C0C0C0C0C0C0C061C0C0C0C0C0022161E0828282C0C0C0C0C2C0C081C0C0C0C003612161C2C2C2C0C0C0C0C0C0C0C061C0C0C0C0C06141610303C043C2C0C0C0C0C0C061C0C0C003C061216161616161616161228161616161616161610221","jaye":{"y":9,"x":15},"tickword":"","moveword":"","objects":[{"x":8,"func":"door","linkword":"","name":"","y":6},{"x":2,"func":"firstterm","y":4,"name":"","linkword":"","link":3},{"x":17,"func":"neutterm","y":8,"name":"","linkword":"","link":2},{"x":13,"func":"switch","y":8,"name":"","linkword":"","link":8},{"link":6,"x":9,"y":1,"linkword":"","name":"","func":"exitscanner"},{"x":10,"linkentity":"level2","func":"exitdoor","y":1,"name":"","linkword":"exitlevel"},{"link":1,"x":6,"y":6,"linkword":"","name":"","func":"switch"},{"x":13,"func":"firstdoor","name":"","linkword":"","y":10}]} \ No newline at end of file diff --git a/game/tiles.fnl b/game/tiles.fnl index 9d73a98..bb4c981 100644 --- a/game/tiles.fnl +++ b/game/tiles.fnl @@ -54,7 +54,14 @@ (if xy (bit.bor (bit.lshift (- xy.y 1) 8) (- xy.x 1)) 0xffff)) (fn encode-itile [itile] - (bit.bor (bit.lshift (bit.band (- itile 1) 0x07) 5) (bit.rshift (bit.band (- itile 1) 0xf8) 3))) + (bit.bor + (bit.lshift (bit.band (- itile 1) 0x07) 5) + (bit.rshift (bit.band (- itile 1) 0xf8) 3))) + +(fn decode-itile [enctile] + (+ 1 (bit.bor + (bit.lshift (bit.band enctile 0x1f) 3) + (bit.rshift (bit.band enctile 0xe0) 5)))) (fn find-itile [tiles label ?itilenext] (local itile (or ?itilenext 1)) @@ -64,5 +71,5 @@ (find-itile tiles label (+ itile 1)))) {: loadgfx : savegfx : appendtiles : appendgfx : flags : flag-to-bit : find-itile - : fn-tiles : fn-portraits : fn-font : encode-yx : encode-itile} + : fn-tiles : fn-portraits : fn-font : encode-yx : encode-itile : decode-itile}