This is a thing from a while ago, but I think its a cool bit of code. Its a map generator that generates crappy city-block style maps. It needs media, so I've attached the whole project, along with the source code visible here:
type statics
kind as integer
rot as integer
texture as integer
endtype
type dynamics
cit as integer
ally as integer
zomb as integer
endtype
type worldgrid
prop as statics
dyn as dynamics
objnum as integer
objkind as integer
zombienum as integer
endtype
type zombmass
x as integer
z as integer
num as integer
endtype
global scale as integer
scale=10
global size as integer
global worldbasenum as integer
size=29
worldbasenum=size*size+8
dim world(memgridsize(size,size,1,0)) as worldgrid
dim zombiehotspot(0) as zombmass
` up right down left
dim roadrot(1, 1, 1, 1) as statics
tempbase=0
roadrot(1,0,1,0).kind=1
roadrot(1,0,1,0).rot=0
roadrot(1,0,1,0).texture=1+tempbase
roadrot(0,1,0,1).kind=1
roadrot(0,1,0,1).rot=90
roadrot(0,1,0,1).texture=1+tempbase
roadrot(0,1,1,0).kind=2
roadrot(0,1,1,0).rot=0
roadrot(0,1,1,0).texture=2+tempbase
roadrot(0,0,1,1).kind=2
roadrot(0,0,1,1).rot=90
roadrot(0,0,1,1).texture=2+tempbase
roadrot(1,0,0,1).kind=2
roadrot(1,0,0,1).rot=180
roadrot(1,0,0,1).texture=2+tempbase
roadrot(1,1,0,0).kind=2
roadrot(1,1,0,0).rot=270
roadrot(1,1,0,0).texture=2+tempbase
roadrot(0,1,1,1).kind=3
roadrot(0,1,1,1).rot=0
roadrot(0,1,1,1).texture=3+tempbase
roadrot(1,0,1,1).kind=3
roadrot(1,0,1,1).rot=90
roadrot(1,0,1,1).texture=3+tempbase
roadrot(1,1,0,1).kind=3
roadrot(1,1,0,1).rot=180
roadrot(1,1,0,1).texture=3+tempbase
roadrot(1,1,1,0).kind=3
roadrot(1,1,1,0).rot=270
roadrot(1,1,1,0).texture=3+tempbase
roadrot(1,1,1,1).kind=4
roadrot(1,1,1,1).rot=0
roadrot(1,1,1,1).texture=4+tempbase
`updown road kind=1
`corner road kind=2
`3way road kind=3
`4way road kind=4
global zombwidth as integer
global return_x as float
global return_z as float
global yplain as float
yplain=0
zomb_speed=1 `(unit/sec)
zombwidth=100
basenum=20
`=========kind flags======
#constant building 1 `==
#constant road 2 `==
#constant baseground 3 `==
`=========================
`================timer variables=============
Global OldTime As Double integer `==
Global TimeGap As Double integer `==
Global FrameGap As Double integer `==
`==
Global Duration As Float `==
Global FPS As Float `==
Global Elapsed As Float `==
Global TBM_Frame As Integer `==
Global TBM_IsPerf As Boolean `==
Global TBM_TotFrames As Integer `==
`============================================
TBM_Init( 50 )
`=======status flags==========
#constant idling 1 ` ==
#constant moving 2 ` ==
`=============================
sync on
sync rate 60
color backdrop rgb(0,0,0)
gosub load_stuff
global skyscraper_object as integer
skyscraper_object=worldbasenum+1
make object skyscraper_object,5,5
set object normals skyscraper_object
set object smoothing skyscraper_object,0
scale object skyscraper_object,scale*50,scale*50,scale*50
position object skyscraper_object,10000,10000,10000
global grass_object as integer
grass_object=worldbasenum+2
make object grass_object,6,6
scale object grass_object,scale*100,scale*100,scale*100
position object grass_object,10000,10000,10000
for a=1 to 4
make object worldbasenum+2+a,a,a
rotate object worldbasenum+2+a,0,0,0
scale object worldbasenum+2+a,scale*50,scale*50,scale*50
position object worldbasenum+2+a,10000,10000,10000
set object normals worldbasenum+2+a
set object smoothing worldbasenum+2+a,0
next
autocam off
add_citygrid(1,1,size,size)
for n=1 to 5
x1=rnd(size-1)+1
z1=rnd(size-1)+1
add_park(x1,z1,x1+rnd(10)+2,z1+rnd(10)+2)
next n
print "ok"
sync
for x=1 to size
for z=1 to size
if is_road(x,z) then updateroad(x,z)
next
NEXT
position camera 0,15*scale,0
point camera size*scale,0,size*scale
sync
for x=1 to size
for z=1 to size
instantiate_tile(x,z)
index=memgridnum(x,z,size,size,1,0)
print "info generated. generating objects: "
print "Index: "+str$(index)+" - object type: "+str$(world(index).prop.kind)
text 100,100,str$(world(index).zombienum/5)
sync
next
NEXT
`fog on
`fog distance 10*scale
do
TBM_update()
text 0,0,str$(Duration)
yrotate camera camera angle y()+mousemovex()/10.0
xrotate camera camera angle x()+mousemovey()/10.0
if mouseclick()=1 then move camera scale*5*Duration
if mouseclick()=2 then move camera -scale*5*Duration
sync
LOOP
load_stuff:
`road stuff
load mesh "media/roads/road.x",1
load mesh "media/roads/roadcorner.x",2
load mesh "media/roads/road3way.x",3
load mesh "media/roads/road4way.x",4
load image "media/roads/road.tga",1
load image "media/roads/roadcorner.tga",2
load image "media/roads/road3way.tga",3
load image "media/roads/road4way.tga",4
load mesh "media/skyscraper.x",5 `building model
load image "media/skyscrapertexture.tga",5 `building texture
make object plain 1000, 1,1 `grass ground
xrotate object 1000,90
make mesh from object 6,1000
delete object 1000
load image "media/grass.jpg",6
make image 7,2,2 `image for the zombies
load mesh "media/l1.x",7 `Basic zombie model
return
function roadbox(x1,z1,x2,z2)
if x1>x2
a=x2
x2=x1
x1=a
ENDIF
if z1>z2
a=z2
z2=z1
z1=a
ENDIF
if x2>size then x2=size
if z2>size then z2=size
for x=x1 to x2
add_road(x,z1)
add_road(x,z2)
NEXT
for z=z1 to z2
add_road(x1,z)
add_road(x2,z)
NEXT
ENDFUNCTION
function grass_fill(x1,z1,x2,z2)
`so that x1<x2 and z1<z2
if x1>x2
a=x2
x2=x1
x1=a
ENDIF
if z1>z2
a=z2
z2=z1
z1=a
ENDIF
if x2>size then x2=size
if z2>size then z2=size
for x=x1 to x2
for z=z1 to z2
add_grass(x,z)
next
NEXT
ENDFUNCTION
function add_park(x1,z1,x2,z2)
if x1>x2
a=x2
x2=x1
x1=a
ENDIF
if z1>z2
a=z2
z2=z1
z1=a
ENDIF
if x1<1 then x1=1
if z1<1 then z1=1
if x2>size then x2=size-1
if z2>size then z2=size-1
roadbox(x1,z1,x2,z2)
grass_fill(x1+1,z1+1,x2-1,z2-1)
endfunction
function add_citygrid(x1,z1,x2,z2)
if x1>x2
a=x2
x2=x1
x1=a
ENDIF
if z1>z2
a=z2
z2=z1
z1=a
ENDIF
if x2>size then x2=size
if z2>size then z2=size
if (x2-x1) mod 2 then dec x2
if (z2-z1) mod 2 then dec z2
for x=x1 to x2
for z=z1 to z2 step 2
add_road(x,z)
next
NEXT
for z=z1 to z2
for x=x1 to x2 step 2
add_road(x,z)
next
NEXT
for x=x1+1 to x2-1 step 2
for z=z1+1 to z2-1 step 2
add_skyscraper(x,z)
next
NEXT
ENDFUNCTION
function instantiate_tile(tilex,tilez)
index=memgridnum(tilex,tilez,size,size,1,0)
if world(index).prop.kind=road and world(index).objkind=0 then world(index).prop.kind=baseground
if world(index).prop.kind=building
instance object world(index).objnum,skyscraper_object
position object world(index).objnum,(tilex-.5)*scale,yplain-.05*scale, (tilez-.5)*scale
scale object world(index).objnum,scale*50,scale*50,scale*50
else
if world(index).prop.kind=road
instance object world(index).objnum,worldbasenum+2+world(index).objkind
rotate object world(index).objnum,0,world(index).prop.rot,0
position object world(index).objnum,(tilex-.5)*scale,yplain, (tilez-.5)*scale
scale object world(index).objnum,scale*50,scale*50,scale*50
else
if world(index).prop.kind=baseground
instance object world(index).objnum,grass_object
position object world(index).objnum,(tilex-.5)*scale,yplain, (tilez-.5)*scale
scale object world(index).objnum,scale*100,scale*100,scale*100
ENDIF
endif
endif
ENDFUNCTION
function add_skyscraper(tilex, tilez)
cleartile(tilex,tilez)
index=memgridnum(tilex,tilez,size,size,1,0)
world(index).prop.kind=building
world(index).prop.rot=0
world(index).prop.texture=5
world(index).objnum=index+1
endfunction
function add_road(tilex,tilez)
cleartile(tilex,tilez)
index=memgridnum(tilex,tilez,size,size,1,0)
world(index).prop.kind=road
world(index).objnum=index+1
upnum=is_road(tilex,tilez+1)
rightnum=is_road(tilex+1,tilez)
downnum=is_road(tilex,tilez-1)
leftnum=is_road(tilex-1,tilez)
if upnum+rightnum+downnum+leftnum>1
world(index).prop.texture=roadrot(upnum,rightnum,downnum,leftnum).texture
world(index).prop.rot=roadrot(upnum,rightnum,downnum,leftnum).rot
endif
if upnum then updateroad(tilex,tilez+1)
if rightnum then updateroad(tilex+1,tilez)
if downnum then updateroad(tilex,tilez-1)
if leftnum then updateroad(tilex-1,tilez)
endfunction
function updateroad(tilex,tilez)
cleartile(tilex,tilez)
index=memgridnum(tilex,tilez,size,size,1,0)
world(index).prop.kind=road
world(index).objnum=index+1
upnum=is_road(tilex,tilez+1)
rightnum=is_road(tilex+1,tilez)
downnum=is_road(tilex,tilez-1)
leftnum=is_road(tilex-1,tilez)
if upnum+rightnum+downnum+leftnum>1
`make object index+1,roadrot(upnum,rightnum,downnum,leftnum).kind,roadrot(upnum,rightnum,downnum,leftnum).texture
`rotate object index+1,0,roadrot(upnum,rightnum,downnum,leftnum).rot,0
`scale object index+1,scale*50,scale*50,scale*50
`position object index+1,(tilex-.5)*scale,yplain, (tilez-.5)*scale
`set object normals index+1
`set object smoothing index+1,0
world(index).objnum=index+1
world(index).prop.texture=roadrot(upnum,rightnum,downnum,leftnum).texture
world(index).prop.rot=roadrot(upnum,rightnum,downnum,leftnum).rot
world(index).objkind=roadrot(upnum,rightnum,downnum,leftnum).kind
endif
ENDFUNCTION
function add_grass(tilex,tilez)
cleartile(tilex,tilez)
index=memgridnum(tilex,tilez,size,size,1,0)
world(index).prop.kind=baseground
world(index).prop.rot=0
world(index).prop.texture=6
world(index).objnum=index+1
endfunction
function cleartile(tilex,tilez)
index=memgridnum(tilex,tilez,size,size,1,0)
if world(index).objnum>0
if object exist(world(index).objnum) then delete object world(index).objnum
endif
world(index).objnum=0
world(index).prop.kind=0
world(index).prop.texture=0
world(index).prop.rot=0
endfunction
function is_road(x,z)
if x<1 or z<1 then exitfunction 0
if x>size or z>size then exitfunction 0
index=memgridnum(x,z,size,size,1,0)
if world(index).prop.kind=road then exitfunction 1
endfunction 0
function forward(x as float, z as float, ang as float, dist as float)
return_x=x+sin(ang)*dist
return_z=z+cos(ang)*dist
ENDFUNCTION
function memgridnum(x, y, xsize, ysize, multiplier, base)
if x<1 or y<1 then exitfunction 0
if x>xsize or y>ysize then exitfunction 0
value=((y-1)*xsize+x-1)*multiplier+base
endfunction value
function memgridsize(xsize,ysize,multiplier,base)
value= xsize*ysize*multiplier+base-1
endfunction value
function addallocate(address,extramemsize)
`Adds memory extramemsize to the memory at location address
`if address is zero, then the memory is allocated.
if address=0
newaddress=alloc(extramemsize)
exitfunction newaddress
endif
newaddress=realloc(address,memory size(address)+extramemsize)
free address
endfunction newaddress
function removemem(address,removeaddress,removesize)
tempvar=memory size(address)
if tempvar<=removesize
free address
exitfunction 0
endif
newaddress=realloc(address,memory size(address)-removesize)
byt as byte
for a=address to memory size(address)-1
if a<removeaddress
byt=peek byte(a)
poke byte newaddress+a-address,byt
else
if a=>removeaddress and a<=removeaddress+removesize-1
`ignore
else
if a>removeaddress+removesize-1
byt=peek byte(a)
poke byte newaddress+a-address-removesize,byt
endif
endif
endif
next a
free address
endfunction newaddress
Function TBM_Init( TweenFrames As Integer ) `//////////////////////////
`// Failsafes
If TweenFrames <= 0
Exit Prompt "Variable 'TweenFrames' must be at least one." , "TBM_Init::Error"
End
Endif
`// TweenFrames
Dim TBM_Tween( TweenFrames ) As Float
TBM_TotFrames = TweenFrames
`// Get ticks per second
Load DLL "kernel32.dll", 1
Ptr = Make Memory(8)
Null = Call Dll(1, "QueryPerformanceFrequency", Ptr )
TimeGap = (*Ptr)
Delete DLL 1
`// Failsafe for older CPUs
If TimeGap > 0
OldTime = Perftimer()
TBM_IsPerf = 1
Else
OldTime = Timer()
Endif
Endfunction `//////////////////////////////////////////////////////////
Function TBM_Update() `////////////////////////////////////////////////
`// Tween
Inc TBM_Frame
If TBM_Frame > TBM_TotFrames
TBM_Frame = 0
Endif
`// Failsafe for older CPUs
If TBM_IsPerf
`// Get Elapsed
FrameGap = Perftimer() - OldTime
OldTime = Perftimer()
`// Tween
FrameGap = TBM_GetAverage( FrameGap )
`// Get other variables
FPS = TimeGap / FrameGap
Elapsed = 1000 / FPS
Duration = Elapsed * 0.001
Else
`// Get Elapsed
Elapsed = Timer() - OldTime
OldTime = Timer()
`// Tween
Elapsed = TBM_GetAverage( Elapsed )
`// Get other variables
FPS = Int( 1000 / Elapsed )
Duration = Elapsed * 0.001
Endif
Endfunction
Function TBM_GetAverage( LatestElapsed As Integer )
Local ReturnValue As Float
`// Add latest Elapsed
TBM_Tween(TBM_Frame) = LatestElapsed
`// Find the average
For TBM = 0 To TBM_TotFrames
ReturnValue = ReturnValue + TBM_Tween(TBM)
Next TBM
ReturnValue = ReturnValue / ( TBM_TotFrames + 1 )
Endfunction ReturnValue
download here:
https://forumfiles.thegamecreators.com/download/2100485
[edit]
and screenshots:

[edit2]
and of course all the media is free fo' anyone to use.