Compare commits
2 Commits
f2c33f880f
...
ab77acc264
Author | SHA1 | Date |
---|---|---|
Nico | ab77acc264 | |
Nico | 3553032a05 |
43
main.fs
43
main.fs
|
@ -47,6 +47,8 @@ create constructcost 0 , 0
|
|||
variable constructcount
|
||||
\ count-messages-shown contains the amount of device count milestone messages that have been shown.
|
||||
variable count-messages-shown
|
||||
\ the variable detector-unlocked stores if the metal detector has been unlocked.
|
||||
variable detector-unlocked
|
||||
\ the variable screen contains the current screen number.
|
||||
\ 0 = devices
|
||||
\ 1 = garden
|
||||
|
@ -92,9 +94,14 @@ S" you feel like throwing some stuff into the pool." set-message
|
|||
30 devices can-afford? constructcost @ 0= and if
|
||||
40 constructcost !
|
||||
S" You figure out that you can probably hack these devices." set-message then ;
|
||||
|
||||
|
||||
: 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.
|
||||
: unlock unlock-members unlock-constructs ;
|
||||
: unlock unlock-members unlock-constructs unlock-detector ;
|
||||
|
||||
\ the word wait-tick waits a tick. Ticks are 1ms currently.
|
||||
: wait-tick 1 ms ;
|
||||
|
@ -159,6 +166,11 @@ S" you feel like throwing some stuff into the pool." set-message
|
|||
clear-message
|
||||
then ;
|
||||
|
||||
\ the word buy-detector buys the metal detector!
|
||||
: buy-detector
|
||||
400 devices can-afford? if
|
||||
1 screens +! then
|
||||
page ;
|
||||
|
||||
\ DEBUGGING STUFF
|
||||
|
||||
|
@ -183,11 +195,20 @@ 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
|
||||
[char] h of hire-chat-member endof
|
||||
[char] b of build-construct endof
|
||||
[char] g of buy-detector endof
|
||||
endcase ;
|
||||
|
||||
\ the word handle-input handles input every time around the game loop.
|
||||
|
@ -196,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.
|
||||
|
@ -276,11 +299,17 @@ S" you feel like throwing some stuff into the pool." set-message
|
|||
else drop then
|
||||
inc-y ;
|
||||
|
||||
: draw-detector ( x y -- x y )
|
||||
detector-unlocked @ screens @ 0= and if
|
||||
." (g)o metal detecting! [400 Devices]"
|
||||
then inc-y ;
|
||||
|
||||
\ draw-actions draws a list of the actions you've unlocked.
|
||||
: draw-actions ( x y -- x y )
|
||||
2dup at-xy
|
||||
draw-members cr over move-right
|
||||
draw-constructs cr over move-right
|
||||
draw-detector cr over move-right
|
||||
." (q)uit (without saving)"
|
||||
\ add 1 to y
|
||||
inc-y ;
|
||||
|
@ -290,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
|
||||
|
@ -304,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 ;
|
||||
|
|
Reference in New Issue