From f1852fdd966f1b2be474a9bad490815bfaecd7a3 Mon Sep 17 00:00:00 2001 From: Jeremy Penner Date: Sun, 2 Feb 2020 18:30:11 -0500 Subject: [PATCH] Add scanner, second level, more office objects. Game is completable! --- end.jor | 10 ++++++ end.map | Bin 0 -> 264 bytes entity.jor | 10 ++++-- footer.jor | 2 +- game.jor | 85 ++++++++++++++++++++++++++++++++++++++------------- gameboot.jor | 3 ++ input.jor | 9 ++++++ lev00001.jor | 33 +++++++++++++++----- lev00001.map | Bin 264 -> 264 bytes lev00002.jor | 59 +++++++++++++++++++++++++++++++++++ lev00002.map | Bin 0 -> 264 bytes map.jor | 37 +++++++++++++--------- portrait.gfx | Bin 8192 -> 8192 bytes tiles.gfx | Bin 8192 -> 8192 bytes 14 files changed, 201 insertions(+), 47 deletions(-) create mode 100755 end.jor create mode 100755 end.map create mode 100755 lev00002.jor create mode 100755 lev00002.map diff --git a/end.jor b/end.jor new file mode 100755 index 0000000..bb3925d --- /dev/null +++ b/end.jor @@ -0,0 +1,10 @@ +( E N D ) + +:noname + reset-level + + s" end.map" load-map + 7 11 tile>world pjaye entity.pos! + 6 12 tile>world pneut entity.pos! + +; ' onload redefine diff --git a/end.map b/end.map new file mode 100755 index 0000000000000000000000000000000000000000..65748d4c6b3ace54a138b8b4a0ee31ed76c0c507 GIT binary patch literal 264 zcmZ8aF%rNa3__ebxb^>UEd+C?Ma3KmJ!6rt-Fv` qUTdDyn=@V&2RM>vyXV}BH|gQ_Draxaj@o;qwfB;0Z#ntoGXo!Sssg(J literal 0 HcmV?d00001 diff --git a/entity.jor b/entity.jor index cfe04ee..97f8ae6 100755 --- a/entity.jor +++ b/entity.jor @@ -1,8 +1,9 @@ 0 const EVTICK 1 const EVTOUCH -2 const EVACT -3 const EVDEACT -4 const EVTOG +2 const EVUNTOUCH +3 const EVACT +4 const EVDEACT +5 const EVTOG : world>tile 4 >> swap 4 >> swap ; userword : tile>world 4 << swap 4 << swap ; userword @@ -24,13 +25,16 @@ var _responder : entity>sprite cell + @ execute ; : entity>do ( entity event ) swap dup if + responder >rot dup _responder ! @ execute + _responder ! else drop drop then ; : entity>pos dup entity.x @ swap entity.y @ ; userword : entity.pos! ( x y entity ) r 2dup ( x y x y r:e ) - r@ entity.x @ r@ entity.y @ world>tile 2= ( x y b r:e ) + r@ entity>pos world>tile 2= ( x y b r:e ) if pos world>tile entity-at + dup if EVUNTOUCH entity>do else drop then + 1 player.state MOVING f! isneut? not if ( only jaye can have a party ) @@ -98,7 +103,7 @@ defer neut-touch ( x y -- b ) player entity-dst check-player-touch not if move-player then ; : follow ( e -- ) - player entity>pos pos world player entity.pos! party each follow more else drop then ; @@ -204,10 +206,12 @@ does> @ objects ! ; 10 const DOOR-OPENED 11 const SWITCH-OFF 12 const SWITCH-ON - +20 const SCAN-OFF +21 const SCAN-ON : entity>tile ( entity -- tile ) entity>pos world>tile tile ; : entity>tile? ( entity expected - b ) swap entity>tile b@ = ; +: responder>tile? ( expected - b ) responder swap entity>tile? ; : toggleval ( off on val -- off|on ) over = not if swap then drop ; : toggletile ( entity off on -- ) @@ -225,32 +229,71 @@ does> @ objects ! ; : blankentity array here >r N ' {duck} allotentity tile? if EVACT else EVDEACT then - responder entity.user @ swap entity>do + responder>tile? if EVACT else EVDEACT then + linked-entity swap entity>do else drop then ; -: door blankentity dup link-object - :| dup EVTOUCH = isjaye? and responder DOOR-OPENED entity>tile? and if - move-player - then - DOOR-OPENED DOOR-CLOSED handle-onoff - |; swap ! ; +: computer-on? ( entity -- b ) COMP-ON entity>tile? ; -: switch blankentity swap , dup link-object +: handle-teleport ( ev -- ) + EVTOUCH = isneut? and COMP-ON responder>tile? and if + linked-entity dup computer-on? if + entity>pos pneut entity.pos! + else drop then + then ; + +: create-object blankentity dup link-object ; +: create-linked-object blankentity swap , dup link-object ; +: listener! ( entity listener ) swap ! ; + +: entering-door? ( ev -- b ) + EVTOUCH = isjaye? and DOOR-OPENED responder>tile? and ; + +: door-listener ( ev -- ) + dup entering-door? if move-player then + DOOR-OPENED DOOR-CLOSED handle-onoff ; + +: door create-object ' door-listener listener! ; + +: exitdoor create-linked-object + :| dup door-listener entering-door? if + responder entity.user @ queue-level + then |; listener! ; + +: switch create-linked-object :| dup EVTOUCH = isneut? and if move-player then - dup EVTOUCH = if responder EVTOG entity>do then + dup EVTOUCH = if + responder EVTOG entity>do + isjaye? if wait-for-arrow-up then + then dup SWITCH-ON SWITCH-OFF handle-onoff - SWITCH-ON handle-link |; swap ! ; + SWITCH-ON handle-link |; listener! ; : computer blankentity swap , dup link-object :| dup EVTOUCH = isjaye? and if responder EVACT entity>do then - dup EVTOUCH = isneut? and if move-player then + dup EVTOUCH = isneut? and COMP-ON responder>tile? and if move-player then dup COMP-ON COMP-OFF handle-onoff - COMP-ON handle-link |; swap ! ; + handle-teleport |; listener! ; -: chainev ( entity xp -- ) swap dup @ , ! ; immediate +: scanner create-linked-object + :| dup EVTOUCH = isneut? and if + move-player + responder EVACT entity>do + then + dup EVUNTOUCH = isneut? and if responder EVDEACT entity>do then + dup SCAN-ON SCAN-OFF handle-onoff + SCAN-ON handle-link |; listener! ; + +( usage: entity :noname [ ev -- ev ] ... chain-listener ; + ONLY works with :noname at top-level interpretation time - not :| |; + compiles a reference to the previous listener into the :noname func + and sets the listener of the entity on the stack to the new func ) + +: chain-listener ( entity xp -- ) swap dup @ , ! ; immediate :noname reset-level diff --git a/gameboot.jor b/gameboot.jor index c89bde0..38b6302 100755 --- a/gameboot.jor +++ b/gameboot.jor @@ -28,8 +28,11 @@ s" game.jor" loadfile ; execute intern lev00001.jor +intern lev00002.jor +intern end.jor :noname loadfile ; checkpoint _loadlevel ' _loadlevel ' loadlevel redefine lev00001.jor loadlevel + diff --git a/input.jor b/input.jor index 95d7763..98ce872 100755 --- a/input.jor +++ b/input.jor @@ -20,6 +20,15 @@ swap - then ; +: current-arrows + ^UP key-down if 0x01 else 0 then + ^DOWN key-down if 0x02 else 0 then | + ^LEFT key-down if 0x04 else 0 then | + ^RIGHT key-down if 0x08 else 0 then | ; + +: wait-for-arrow-up + current-arrows begin dup current-arrows & while suspend repeat drop ; + ( M O U S E ) var prevbutton : tick-debounce diff --git a/lev00001.jor b/lev00001.jor index 38605f0..9dd430b 100755 --- a/lev00001.jor +++ b/lev00001.jor @@ -13,18 +13,24 @@ objects: O +defer last-term + 12 9 door d1 -d1 12 8 switch s1 -0 15 8 computer c1 +' d1 12 8 switch s1 +' last-term 15 8 computer c1 7 6 door d2 -d2 6 6 switch s2 -0 1 4 computer c2 +' d2 6 6 switch s2 +' c1 1 4 computer c2 +' c2 ' last-term redefine + +lev00002.jor 10 0 exitdoor dexit +' dexit 9 0 scanner sexit d1 :noname dup EVTOUCH = isjaye? and d1 DOOR-CLOSED entity>tile? and if jaye say" It won't open!" - then chainev ; + then chain-listener ; c1 :noname dup EVTOUCH = isjaye? and if @@ -37,19 +43,30 @@ c1 :noname else jaye say" Neut is running now.\I can hit the space bar\to control them." then - then chainev ; + then chain-listener ; c2 :noname dup EVTOUCH = isjaye? and if c2 COMP-OFF entity>tile? if jaye say" Looks like there's still\power to this terminal." then jaye say" If I turn a terminal on,\Neut can use it to\travel through the network." - then chainev ; + then chain-listener ; + +sexit :noname + dup EVTOUCH = isjaye? and if + jaye say" It's a card scanner.\It should open this door." + jaye say" It's not reading my card\for some reason.\Quake must've damaged it." + jaye say" Neut might be able to\hack it..." + then chain-listener ; :noname reset-level O s" lev00001.map" load-map -( ' intro sched ) + 0 player.state HASNEUT f! + 14 9 tile>world pjaye entity.pos! + c1 entity>pos pneut entity.pos! + + ' intro sched ; ' onload redefine diff --git a/lev00001.map b/lev00001.map index d8c833790bffc864c651cbdf89393ff92cca2685..e283bbf0185b9a0141d611531d722e72303a8824 100755 GIT binary patch literal 264 zcmYL?3lhX22t$!{&`w9)ZF~Q-Hb6gd6pRmZN*8@}u6HM*bK)2XDe!~RGizqA_or8M z)Cwd>4%4~CL0)LDj(2)qZ+UOdg|-aciMuzD5e>-q^37JXtzn5-AR>rGM)eH;BQuW3 Ri;T{1xV>oSDTV9N+g(eR1P%ZI literal 264 zcma)0?FxWE2-9_39*6&W|7Xp46d?so{6MzpAuiYoAb)rIs%^#3Km0(sT)3wbnl%Fe diff --git a/lev00002.jor b/lev00002.jor new file mode 100755 index 0000000..26b939e --- /dev/null +++ b/lev00002.jor @@ -0,0 +1,59 @@ +( L E V E L 0 0 0 0 2 ) + +objects: O + +11 9 door d1 +13 8 door d2 +15 7 door d3 +13 3 door d4 +9 4 door d5 +7 5 door d6 +8 10 door d7 +4 9 door d8 +2 6 door d9 +4 2 door d10 + +end.jor 7 0 exitdoor dx +' dx 6 0 scanner sx + +: unconnected :| 0 |; ; +defer c10 ' c10 5 1 computer cx +' cx 5 4 computer _c10 ' _c10 ' c10 redefine +defer c8 ' c8 11 4 computer c9 +' c9 16 1 computer _c8 ' _c8 ' c8 redefine +defer c6 ' c6 16 10 computer c7 +' c7 14 6 computer _c6 ' _c6 ' c6 redefine +defer c3 ' c3 10 6 computer c5 +defer c2 ' c2 5 6 computer c4 +' c5 1 9 computer _c3 ' _c3 ' c3 redefine +' c4 1 2 computer _c2 ' _c2 ' c2 redefine +' c2 9 11 computer c1 + +' d7 0 4 scanner sc1 +' d3 10 0 scanner sc2 +' d1 11 0 scanner sc3 +' d5 12 0 scanner sc4 +' d2 13 7 scanner sc5 +' d4 17 9 scanner sc6 + +' c3 13 6 switch s1 +' d6 14 0 switch s2 +' d8 15 0 switch s3 +' d9 16 0 switch s4 +' d10 2 0 switch s5 + +c2 :noname + dup EVTOUCH = isneut? and c4 computer-on? not and if + neut say" DESTINATION TERMINAL\IS DISCONNECTED" + neut say" PLEASE CONTACT YOUR\SYSTEM ADMINISTRATOR" + neut say" THIS INCIDENT HAS\BEEN REPORTED" + then chain-listener ; + +:noname + reset-level O + + s" lev00002.map" load-map + 11 11 tile>world pjaye entity.pos! + 10 12 tile>world pneut entity.pos! + +; ' onload redefine diff --git a/lev00002.map b/lev00002.map new file mode 100755 index 0000000000000000000000000000000000000000..158191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