make drawing commands pass position through the stack

This commit is contained in:
Nico 2021-03-22 10:32:36 +00:00
parent 4ec3c66df6
commit d6e037bb5c
1 changed files with 27 additions and 12 deletions

39
main.fs
View File

@ -164,6 +164,9 @@ S" you feel like throwing some stuff into the pool." set-message
[char] b of build-construct endof
[char] D of debug-console endof
endcase then ;
\ inc-y increments the y coordinate being drawn at.
: inc-y 1 + ;
\ print-rate prints the current device output rate on the screen.
: print-rate
@ -172,21 +175,25 @@ S" you feel like throwing some stuff into the pool." set-message
." (" devices/tick 1000e f* f. ." devices/second)" ;
\ draw-message draws the stored message on the screen.
: draw-message
1 2 at-xy
clear-line get-message type ;
: draw-message ( x y -- x y )
2dup at-xy
clear-line get-message type
inc-y ;
\ draw-devices draws the number of devices on the screen.
: draw-devices
: draw-devices ( x y -- x y )
2dup at-xy
devices f@ f>s dup
1 1 at-xy
clear-line
1 = if ." There is 1 device in the javapool." drop else
." There are " . ." devices in the javapool." then
space print-rate ;
space print-rate
\ increment y position
inc-y ;
\ draw-constructs draws the option for building a construct
: draw-constructs
: draw-constructs ( x y -- x y )
2dup at-xy
clear-line
constructcost @ dup !0= if
." (b)uild a device-throwing construct [" . ." Devices]"
@ -194,22 +201,30 @@ S" you feel like throwing some stuff into the pool." set-message
else drop then ;
\ draw-members draws the option for hiring a chat member
: draw-members
: draw-members ( x y -- x y )
2dup at-xy
clear-line
membercost @ dup !0= if \ if membercost is non-zero (members have been unlocked)
." (h)ire a chat member [" . ." Devices]"
space ." (" membercount @ 0 .R ." )"
else drop then ;
else drop then
inc-y ;
\ draw-actions draws a list of the actions you've unlocked.
: draw-actions
1 4 at-xy
2dup at-xy
draw-members cr 1 move-right
draw-constructs cr 1 move-right
." (q)uit (without saving)" ;
." (q)uit (without saving)"
\ add 1 to y
1 + ;
\ clear-xy clears the x and y positions from the stack
: clear-xy ( x y -- ) drop drop ;
\ draw-screen redraws the screen, but only if there's been a change.
: draw-screen any-change? if draw-devices draw-actions draw-message clear-all then ;
\ 1 1 is the starting position to draw from.
: draw-screen any-change? if 1 1 draw-devices draw-message draw-actions clear-xy clear-all then ;
\ : draw-screen clear-all ;
\ main game loop