' b+ mod NOVARSEG code for 2 tiler 2021-01-25
' 2021-01-27 mod this for navigation and toggle paint jobs red and back or blue and black as per NOVARSEG
' 2021-01-27 add spacebar to reverse a cells walls a sound will buzz if not inside a cell with walls
' The color your standing on will PAINT the new roadway if the walls switch.
CONST W
= 1024, H
= 700 ' screen width and height and color for lines and border check _DELAY .25 'wait for screen to set white = &HFFFFFFFF
s = 10 ' s is the unit for drawing and navigating screen each step is 2*s
t = .5 ' t is splitter between up/down walls and left/right walls
_TITLE "Press z increase over/under, x increase left/right, c makes smaller cells, v bigger, esc to quit, left mouse paints red/black, right blue/black, spacebar to reverse cells" xcells
= INT(W
/ s
) 'how many cells across ycells
= INT(H
/ s
) 'how many down REDIM maze
(xcells
+ 2, ycells
+ 2) AS LONG ' save our wall settings in maze array for wall changing with spacebar 'CIRCLE (x, y), 2, &HFFFFFF00
maze
(INT(x
/ s
), INT(y
/ s
)) = -1 LINE (x
- s
, y
+ s
)-(x
+ s
, y
+ s
) 'bottom line LINE (x
- s
, y
- s
)-(x
+ s
, y
- s
) 'top line maze
(INT(x
/ s
), INT(y
/ s
)) = 1 LINE (x
- s
, y
- s
)-(x
- s
, y
+ s
) 'left line LINE (x
+ s
, y
- s
)-(x
+ s
, y
+ s
) 'right line x = x + s * 2: y = y + s * 2 ' offset to do the other half of screen
'CIRCLE (x, y), 2, &HFF0000FF
maze
(INT(x
/ s
), INT(y
/ s
)) = -1 LINE (x
- s
, y
+ s
)-(x
+ s
, y
+ s
) 'bottom line LINE (x
- s
, y
- s
)-(x
+ s
, y
- s
) 'top line maze
(INT(x
/ s
), INT(y
/ s
)) = 1 LINE (x
- s
, y
- s
)-(x
- s
, y
+ s
) 'left line LINE (x
+ s
, y
- s
)-(x
+ s
, y
+ s
) 'right line x = x - s * 2: y = y - s * 2 ' set back to first set
_PUTIMAGE , 0, back
'store current maze into image xcells
= INT(W
/ s
) 'how many cells across ycells
= INT(H
/ s
) 'how many down hx
= INT(xcells
/ 2) 'put our guy smack in middle of screen but he has to be on even number of cells! IF maze
(hx
, hy
) THEN ' make sure on a cell that has walls maze(hx, hy) = -1
maze(hx, hy) = 1
' now redraw everything!!!!
hColr
= POINT(hx
* s
- (s
- 1), hy
* s
- (s
- 1)) ' preserve color at hx, hy LINE (x
* s
- s
, y
* s
+ s
)-(x
* s
+ s
, y
* s
+ s
) 'bottom line LINE (x
* s
- s
, y
* s
- s
)-(x
* s
+ s
, y
* s
- s
) 'top line LINE (x
* s
- s
, y
* s
- s
)-(x
* s
- s
, y
* s
+ s
) 'left line LINE (x
* s
+ s
, y
* s
- s
)-(x
* s
+ s
, y
* s
+ s
) 'right line IF hColr
<> white
THEN PAINT (hx
* s
, hy
* s
), hColr
, white
' paint the new roadway 'take a new picture
_PUTIMAGE , 0, back
'store current maze into image 'CIRCLE (hx * s, (hy - 1) * s), 5, &HFFFFFF00
'_DELAY .5
'PRINT POINT(hx * s, (hy - 1) * s), POINT(hx * s, (hy - 1) * s + 1), POINT(hx * s, (hy - 1) * s - 1), white
'_DISPLAY
'SLEEP
IF POINT(hx
* s
, (hy
- 1) * s
) <> white
AND POINT(hx
* s
, (hy
- 1) * s
+ 1) <> white
AND POINT(hx
* s
, (hy
- 1) * s
- 1) <> white
THEN hy
= hy
- 2 CASE 19712 'the RIGHT ARROW key 'CIRCLE ((hx + 1) * s, hy * s), 5, &HFFFFFF00
'_DELAY .5
IF POINT((hx
+ 1) * s
, hy
* s
) <> white
AND POINT((hx
+ 1) * s
+ 1, hy
* s
) <> white
AND POINT((hx
+ 1) * s
- 1, hy
* s
) <> white
THEN hx
= hx
+ 2 CASE 20480 ' the DOWN ARROW key 'CIRCLE (hx * s, (hy + 1) * s), 5, &HFFFFFF00
'_DELAY .5
IF POINT(hx
* s
, (hy
+ 1) * s
) <> white
AND POINT(hx
* s
, (hy
+ 1) * s
+ 1) <> white
AND POINT(hx
* s
, (hy
+ 1) * s
- 1) <> white
THEN hy
= hy
+ 2 CASE 19200 'the LEFT ARROW key 'CIRCLE ((hx - 1) * s, hy * s), 5, &HFFFFFF00
'_DELAY .5
IF POINT((hx
- 1) * s
, hy
* s
) <> white
AND POINT((hx
- 1) * s
+ 1, hy
* s
) <> white
AND POINT((hx
- 1) * s
- 1, hy
* s
) <> white
THEN hx
= hx
- 2 FOR ra
= 0 TO .5 * s
STEP .25 ' make a solid filled circle CIRCLE (hx
* s
, hy
* s
), ra
, &HFFFFFF00
' the rest of this loop is input from user, the drawing part is over but might PAINT roadways
_PUTIMAGE , 0, back
'store current maze into image _PUTIMAGE , 0, back
'store current maze into image IF i$
= "z" AND t
< 1 THEN t
= t
+ .05:
EXIT DO ' changed from .005 because too slow