The "map" is stored into RoadMatrix.
Code: Select all
screenres 800,600
dim x as integer
dim y as integer
dim b as integer
dim RoadMatrix (100,100) as ubyte
sub DrawTile (x as integer,y as integer,i as integer)
if i and 1 then
'line (x*32,y*32)-(x*32+32,y*32+32),0,bf
select case i
case 1
case 3,5,7
line (x*32,y*32)-(x*32,y*32+32)
line (x*32+32,y*32)-(x*32+32,y*32+32)
line (x*32+16,y*32)-(x*32+16,y*32+32),,,49159
case 11
line (x*32,y*32)-(x*32+32,y*32+32),0,bf
circle (x*32+32,y*32+32),32,,90 / 180 * 3.14159,180 / 180 * 3.14159
case 13
line (x*32,y*32)-(x*32+32,y*32+32),0,bf
circle (x*32+32,y*32),32,,180 / 180 * 3.14159,270 / 180 * 3.14159
case 15
line (x*32,y*32)-(x*32+32,y*32+32),0,bf
line (x*32,y*32)-(x*32,y*32+32)
line (x*32+32,y*32+1)-(x*32+32,y*32+16)
line (x*32+16,y*32)-(x*32+16,y*32+32),,,49159
case 19
line (x*32,y*32)-(x*32+32,y*32+32),0,bf
circle (x*32,y*32+32),32,,0 / 180 * 3.14159,90 / 180 * 3.14159
case 21
line (x*32,y*32)-(x*32+32,y*32+32),0,bf
circle (x*32,y*32),32,,270 / 180 * 3.14159,360 / 180 * 3.14159
case 23
line (x*32,y*32)-(x*32+32,y*32+32),0,bf
line (x*32,y*32+16)-(x*32,y*32+31)
line (x*32+32,y*32)-(x*32+32,y*32+32)
line (x*32+16,y*32)-(x*32+16,y*32+32),,,49159
case 25,9,17
line (x*32,y*32)-(x*32+32,y*32)
line (x*32,y*32+32)-(x*32+32,y*32+32)
line (x*32,y*32+16)-(x*32+32,y*32+16),,,49159
case 27
line (x*32,y*32)-(x*32+32,y*32+32),0,bf
line (x*32,y*32)-(x*32+32,y*32)
line (x*32+16,y*32+32)-(x*32+31,y*32+32)
line (x*32,y*32+16)-(x*32+32,y*32+16),,,49159
case 29
line (x*32,y*32)-(x*32+32,y*32+32),0,bf
line (x*32+1,y*32)-(x*32+16,y*32)
line (x*32,y*32+32)-(x*32+32,y*32+32)
line (x*32,y*32+16)-(x*32+32,y*32+16),,,49159
case 31
line (x*32,y*32)-(x*32+32,y*32+32),0,bf
line (x*32+1,y*32)-(x*32+16,y*32)
line (x*32,y*32+16)-(x*32,y*32+31)
line (x*32+16,y*32+32)-(x*32+31,y*32+32)
line (x*32+32,y*32+1)-(x*32+32,y*32+16)
case else
draw string (x*32,y*32),str(i)
end select
end if
end sub
do
'Bit:
'1o=centro, 2o=nord, 3o=sud, 4o=est, 5o=ovest
getmouse x,y,,b
x=x/32:y=y/32
if b=1 then
RoadMatrix(x,y)=RoadMatrix(x,y) or 1
RoadMatrix(x+1,y)=RoadMatrix(x+1,y) or 16
RoadMatrix(x-1,y)=RoadMatrix(x-1,y) or 8
RoadMatrix(x,y+1)=RoadMatrix(x,y+1) or 4
RoadMatrix(x,y-1)=RoadMatrix(x,y-1) or 2
DrawTile x,y+1,RoadMatrix(x,y+1)
DrawTile x,y-1,RoadMatrix(x,y-1)
DrawTile x-1,y,RoadMatrix(x-1,y)
DrawTile x+1,y,RoadMatrix(x+1,y)
DrawTile x,y,RoadMatrix(x,y)
elseif b=2 then
RoadMatrix(x,y)=RoadMatrix(x,y) and not 1
RoadMatrix(x+1,y)=RoadMatrix(x+1,y) and not 16
RoadMatrix(x-1,y)=RoadMatrix(x-1,y) and not 8
RoadMatrix(x,y+1)=RoadMatrix(x,y+1) and not 4
RoadMatrix(x,y-1)=RoadMatrix(x,y-1) and not 2
line (x*32-31,y*32+1)-(x*32+63,y*32+31),0,bf
line (x*32+1,y*32-31)-(x*32+31,y*32+63),0,bf
DrawTile x,y+1,RoadMatrix(x,y+1)
DrawTile x,y-1,RoadMatrix(x,y-1)
DrawTile x-1,y,RoadMatrix(x-1,y)
DrawTile x+1,y,RoadMatrix(x+1,y)
DrawTile x,y,RoadMatrix(x,y)
end if
loop until inkey=chr(27)