How woul i go about creating a random tilebased map
How woul i go about creating a random tilebased map
So what's the basic idea to do it.
Re: How woul i go about creating a random tilebased map
You need some formula according to which you to edit the map. For example you can generate rooms and then connect them via pathways.
You can use the EditMap command to set tile values of a tilemap.
You can use the EditMap command to set tile values of a tilemap.
Code: Select all
EDITMAP map, layer, x, y, tile
- map The tilemap object.
- layer: 0 = background, 1 = over, 2 = collision, 3 = data
- x: Horizontal tile coordinate.
- y: Vertical tile coordinate.
- tile: Tile index
Code: Select all
FrameLimit 40
'Create a map from Blank
map=MakeMap(32,32,32,32)
u=LoadObject("Media\guy.bmp",72)
'Apply some graphics on it
tileset=LoadImage("Media\tileset.bmp")
PaintObject map,tileset
'Randomly fill the map
For y=1 To MapHeight()
For x=1 To MapWidth()
If Rand(1,5)=5 Then
EditMap map,0,x,y,2 'drawing
EditMap map,2,x,y,1 'collision
Else
EditMap map,0,x,y,145
EndIf
Next x
Next y
'The game loop-itself
Repeat
If UpKey() Then MoveObject u,2
If DownKey() Then MoveObject u, -2
If LeftKey() Then TurnObject u,5
If RightKey() Then TurnObject u, -5
'Glue camera to object position
CloneCameraPosition u
DrawScreen
Forever