( M A P ) var tileselect : invalidate-map mapsize mapsize! ; : mouseworldpos mousepos scrollpos +pos ; : mousetile mouseworldpos world>tile ; : tile ( x y -- ptr ) mapsize drop * + map + ; 1 const WALKABLE 2 const DRIVABLE 4 const BOATABLE array tileflags ( grass ) WALKABLE b, ( dirt ) WALKABLE DRIVABLE | b, ( water ) BOATABLE b, ( pavement ) WALKABLE DRIVABLE | b, ( brick ) 0 b, ( forest ) 0 b, ( roof ) 0 b, ( brick ) 0 b, ( window ) 0 b, ( carpet ) WALKABLE b, ( wallpaper ) 0 b, ( tile ) WALKABLE b, ( door ) 0 b, ( cabinet ) 0 b, ( fridge ) 0 b, ( countertop ) 0 b, ( sink ) 0 b, ( house ) 0 b, ( fence ) 0 b, ( storefront ) 0 b, ( space ) 0 b, ( space2 ) BOATABLE b, ( ice ) WALKABLE b, ( ringstl ) WALKABLE b, ( ringstr ) WALKABLE b, ( ringsbl ) WALKABLE b, ( ringsbr ) WALKABLE b, ( hoglinev ) WALKABLE b, ( hoglineh ) WALKABLE b, here tileflags - 1 - const MAXTILE : mapflag? ( x y flag -- b ) >rot tile b@ tileflags + b@ & ; : tick-mapedit tileselect @ ^< key-pressed if 1 - then ^> key-pressed if 1 + then dup 0 < if drop MAXTILE then dup MAXTILE > if drop 0 then tileselect ! MOUSEL mousedown if tileselect @ mousetile tile b! invalidate-map then MOUSER clicked if mouseworldpos world>tile 2dup tile b@ tileselect ! swap . . cr then ; : copy-mapseg ( neww oldw y -- ) >r ( oldw neww r: y ) 2dup min >rot ( copyw neww oldw ) r@ * map + ( copyw neww src ) swap r ( newh neww oldw r: oldh ) 2dup < if 1 r ( dx dy r: h ) swap mapw over abs - >rot ( w dy dx r: h ) 2dup map swap offset-map swap mapw * offset-map >rot ( w end dy dx r: h ) map swap negate offset-map swap mapw * negate offset-map ( w end start r: h ) 2dup > if r@ mapw * + swap r@ mapw * + swap then