From c8531f99175be79fa9690f5c83ba54bc7688d0cb Mon Sep 17 00:00:00 2001 From: Jeremy Penner Date: Thu, 26 Nov 2020 23:46:36 -0500 Subject: [PATCH] Implement some level 1 dialogue --- game/defs.fnl | 7 ++++++- game/entity.fnl | 5 +---- game/init.fnl | 4 ++-- game/level1.fnl | 15 +++++++++++++-- game/map00001.json | 2 +- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/game/defs.fnl b/game/defs.fnl index 05c1332..ca04bf4 100644 --- a/game/defs.fnl +++ b/game/defs.fnl @@ -3,6 +3,7 @@ (local lume (require :lib.lume)) (local asm (require :asm.asm)) (local VM (require :asm.vm)) +(local tiles (require :game.tiles)) (local prg (asm.new)) (local vm (VM.new prg)) @@ -99,5 +100,9 @@ (table.insert result :dismiss-dialog) result) -{: vm : prg : mapw : maph : mon : org : achar : astr : rot8l : deflevel : with-footer : say} +(local itile + (let [tilelist (tiles.loadgfx tiles.fn-tiles)] + (fn [label] (tiles.find-itile tilelist label)))) + +{: vm : prg : mapw : maph : mon : org : achar : astr : rot8l : deflevel : with-footer : say : itile} diff --git a/game/entity.fnl b/game/entity.fnl index 468fbd3..74ade0c 100644 --- a/game/entity.fnl +++ b/game/entity.fnl @@ -1,10 +1,7 @@ (local util (require :lib.util)) (local tiles (util.require :game.tiles)) -(local {: vm : org} (require :game.defs)) +(local {: vm : org : itile} (require :game.defs)) (local {: lo : hi} util) -(local itile - (let [tilelist (tiles.loadgfx tiles.fn-tiles)] - (fn [label] (tiles.find-itile tilelist label)))) ; Entity memory layout: ; +0 - yx diff --git a/game/init.fnl b/game/init.fnl index b45e82d..e74e37e 100644 --- a/game/init.fnl +++ b/game/init.fnl @@ -1,9 +1,9 @@ (local util (require :lib.util)) (local {: lo : hi : readjson} util) (local lume (require :lib.lume)) -(local {: prg : vm : org : mapw : maph} (require :game.defs)) - (local tile (util.reload :game.tiles)) +(local {: prg : vm : org : mapw : maph} (util.reload :game.defs)) + (util.reload :game.gfx) (util.reload :game.map) (util.reload :game.entity) diff --git a/game/level1.fnl b/game/level1.fnl index 76aa0ff..8f90f5c 100644 --- a/game/level1.fnl +++ b/game/level1.fnl @@ -1,5 +1,16 @@ -(local {: deflevel} (require :game.defs)) - +(local {: deflevel : with-footer : say : itile} (require :game.defs)) +(local {: ev} (require :game.entity)) (local level (deflevel "game/map00001.json")) +(local vm level.vm) + +(vm:word :exitscanner (with-footer + (say :jaye "IT'S A CARD SCANNER." "IT SHOULD OPEN THIS DOOR.") + (say :jaye "IT'S NOT READING MY CARD" "FOR SOME REASON." "QUAKE MUST'VE DAMAGED IT.") + (say :jaye "NEUT MIGHT BE ABLE TO" "HACK IT..."))) + +(vm:word :firstdoor + :dup ev.touch := :responder-itile (itile :doorclosed) := :& (vm:when + (with-footer (say :jaye "IT WON'T OPEN!")) + ) :door) level diff --git a/game/map00001.json b/game/map00001.json index b338771..072e9ea 100644 --- a/game/map00001.json +++ b/game/map00001.json @@ -1 +1 @@ -{"map":"212121214121212121212121212141212121212161026161610261616102616161616102616161216143C0C0E2C0C0C0C0C0C06361C0C0C0C0C0612161C0C0A282C0C0C0A2C0C0C081C0C0C0C0C2024161C0C0C0C0C0C0C0C0C2C0A2C1A2C0C0E082612161E2C08282C0C0C0C0A2C0C06161616161616121616161616161C181616161616143C0C0E282612161C0C0C0C0C0C0C0C0C0C0C061C0C0C0C0C0022161E08282A2C0C0C0C0E2C0C081C0C0C0C003612161E2C2C2C0C0C0C0C0C0C0C061C0C0C0C0C06141610303C063E2C0C0C0C0C0C061C0C0C023C061216161616161616161228161616161616161610221","objects":[{"link":2,"y":6,"func":"switch","name":"","linkword":"","x":7},{"x":8,"func":"door","y":6,"linkword":"","name":""},{"x":2,"link":4,"func":"term","linkword":"","name":"","y":4},{"x":17,"link":3,"func":"term","linkword":"","name":"","y":8},{"x":13,"link":6,"func":"switch","linkword":"","name":"","y":8},{"x":13,"func":"door","linkword":"","name":"","y":9}]} \ No newline at end of file +{"map":"212121214121212121212121212141212121212161026161610261616102616161616102616161216143C0C0E2C0C0C0C0C0C06361C0C0C0C0C0612161C0C0A282C0C0C0A2C0C0C081C0C0C0C0C2024161C0C0C0C0C0C0C0C0C2C0A2C1A2C0C0E082612161E2C08282C0C0C0C0A2C0C06161616161616121616161616161C181616161616143C0C0E282612161C0C0C0C0C0C0C0C0C0C0C061C0C0C0C0C0022161E08282A2C0C0C0C0E2C0C081C0C0C0C003612161E2C2C2C0C0C0C0C0C0C0C061C0C0C0C0C06141610303C063E2C0C0C0C0C0C061C0C0C023C061216161616161616161228161616161616161610221","objects":[{"link":2,"x":7,"y":6,"linkword":"","name":"","func":"switch"},{"x":8,"func":"door","name":"","linkword":"","y":6},{"link":4,"y":4,"func":"term","name":"","linkword":"","x":2},{"link":3,"y":8,"func":"term","name":"","linkword":"","x":17},{"link":6,"y":8,"func":"switch","name":"","linkword":"","x":13},{"x":13,"func":"firstdoor","y":9,"linkword":"","name":""},{"x":9,"func":"exitscanner","linkword":"","name":"","y":1}]} \ No newline at end of file