2 "padding_x" store 2 "padding_y" store 10 "ntiles_x" store 12 "ntiles_y" store 3 "tile_sizex" store 2 "tile_sizey" store @defun "io_pos_windowstart" { #puts: x y 0 0 } @defun "io_pos_windowend" { #puts: x y ntiles_x tile_sizex * padding_x 2 * + 1 - ntiles_y tile_sizey * padding_y 2 * + } @defun "io_pos_after" { #puts: x y 0 ntiles_y tile_sizey * padding_y 2 * + 1 + } @defun "io_clearscreen" { "\x1B[2J\x1B[H" print } @defun "io_goto" { #args: x y "y" store "x" store #"going to (" x + "," + y + ")" + print "\x1B[" y 1 + + ";" + x 1 + + "H" + print } @defun "io_box" { #args: x y w h; w/h are the distances from edge to edge #stackdump #1000000 sleep "h" store "w" store "y" store "x" store x y io_goto "+" print 0 dup w < while "-" print 1 + dup w < end "+" print #1000000 sleep #"x = " print x print #"y = " print y print x y h + io_goto "+" print 0 dup w < while "-" print 1 + dup w < end "+" print #1000000 sleep #"x = " print x print #"y = " print y print x y 1 + io_goto 0 dup h 1 - < while "|\x1B[D\x1B[B" print #bar, left, down 1 + dup h 1 - < end #1000000 sleep x w + 1 + y 1 + io_goto 0 dup h 1 - < while "|\x1B[D\x1B[B" print #bar, left, down 1 + dup h 1 - < end #1000000 sleep } @defun "io_windowbox" { io_pos_windowstart io_pos_windowend io_pos_windowstart diff2 io_box } @defun "io_square" { #args: x y (equivalent to x y 3 2 io_box) "y" store "x" store x y io_goto "+--+" print x y 1 + io_goto "| |" print x y 2 + io_goto "+--+" print } @defun "io_gsquare" { #args: x y swap tile_sizex * padding_x + swap tile_sizey * padding_y + io_square }