Procedural Generation
How would I make a procedurally generated map in microStudio?
How would I make a procedurally generated map in microStudio?
Procedurally generated maps are a very complex subject and it is nearly impossible to give a short answer (beside: use Google, LOL).
It also depends on what kind of map you would like to create
Do you have more details about what you would like to generate?
init = function()
column = 10
row = 5
columnSize = 16
rowSize = 16
myMap = new Map( column, row, columnSize, rowSize )
maps[ 'myMap' ] = myMap
end
randomMap = function( map )
for x = 0 to map.width
for y = 0 to map.height
if random.nextInt(2) then
map.set( x, y, 'icon')
else
map.set( x, y, 0 )
end
end
end
end
update = function()
end
draw = function()
screen.clear()
screen.drawMap( myMap, 0,0, 100, 100 )
// OR
// screen.drawMap( 'myMap', 0,0, 100, 100 )
randomMap( myMap )
end
@TinkerSmith I am trying to make a top-down tank game in a shoot em up style. I want to create a large map that generates forever.
init = function()
column = 160
row = 120
columnSize = 16
rowSize = 16
myMap = new Map( column, row, columnSize, rowSize )
maps[ 'myMap' ] = myMap
randomMap( myMap )
end
moveMapDown = function( map )
for x = 0 to map.width - 1
for y = 0 to map.height - 1
map.set( x, y, map.get( x, y+ 1 ))
end
end
randomRow( map, map.height - 1 )
end
randomRow = function( map, rowNumber )
for x = 0 to map.width
if random.nextInt(2) then
map.set( x, rowNumber , 'icon')
else
map.set( x, rowNumber , 0 )
end
end
end
randomMap = function( map )
for y = 0 to map.height
randomRow( map, y )
end
end
update = function()
end
draw = function()
screen.clear()
screen.drawMap( myMap, 0,0, 200, 150 )
// OR
// screen.drawMap( 'myMap', 0,0, 100, 100 )
moveMapDown( myMap )
end