From ab77acc2648d5ad5a6e75b5956920c20d75988a9 Mon Sep 17 00:00:00 2001 From: Nihilazo Date: Fri, 2 Apr 2021 16:04:08 +0100 Subject: [PATCH] fix tab bar --- main.fs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/main.fs b/main.fs index 23b3a8c..4e1b98a 100644 --- a/main.fs +++ b/main.fs @@ -97,6 +97,7 @@ S" you feel like throwing some stuff into the pool." set-message : unlock-detector 100 devices can-afford? detector-unlocked @ 0= and if + S" Somebody is tinkering with some devices. Says they can build a metal detector. " set-message -1 detector-unlocked ! then ; \ the word unlock tests to see if any unlock conditions are matched, and unlocks them if they are. @@ -168,7 +169,8 @@ S" you feel like throwing some stuff into the pool." set-message \ the word buy-detector buys the metal detector! : buy-detector 400 devices can-afford? if - 1 screens +! then ; + 1 screens +! then + page ; \ DEBUGGING STUFF @@ -193,6 +195,14 @@ S" you feel like throwing some stuff into the pool." set-message \ END DEBUGGING STUFF +\ move screen moves forward/back x screens. +: move-screen ( x -- ) + screen @ + dup dup + 0 >= swap screens @ <= and if + page + screen ! + else drop then ; + \ the word devices-input contains the input cases specifically for the device counter screen. : devices-input case @@ -207,6 +217,8 @@ S" you feel like throwing some stuff into the pool." set-message screen @ 0= if devices-input then [char] q of exit-game endof [char] D of debug-console endof + [char] > of 1 move-screen endof + [char] < of -1 move-screen endof endcase then ; \ inc-y increments the y coordinate being drawn at. @@ -307,7 +319,7 @@ S" you feel like throwing some stuff into the pool." set-message \ draw-screen redraws the devices screen, but only if there's been a change. \ ( x y -- ) -: draw-devices-screen any-change? if draw-message draw-devices draw-blank draw-actions clear-xy clear-all else clear-xy then ; +: draw-devices-screen draw-message draw-devices draw-blank draw-actions ; \ : draw-screen clear-all ; \ TODO draw the garden, this is a stub @@ -321,7 +333,13 @@ S" you feel like throwing some stuff into the pool." set-message endcase ; \ main game loop -: game-loop begin wait-tick game-tick handle-input 1 1 draw-tab-bar draw-blank draw-screen 0 until ; +: game-loop + begin + wait-tick game-tick handle-input + any-change? if + 1 1 draw-tab-bar draw-blank draw-screen clear-xy clear-all + then + 0 until ; \ for use in the debugging shell : restart page game-loop ;