Procedural Tilemap Generation

K

Kydrago

Guest
Hey all, I was curious if anyone had any tips on procedural level generation in GML 2? I watched a great tutorial by HeartBeast where he discusses using a ds grid and a "controller" that moves around and sets values. The tutorial was posted in 2015 though, and uses the function "tile_add" which I guess doesn't exist in GML 2. There is a similar function called "tilemap _set" but it requires a specific tile id number and functions entirely differently. My question is: is the best workaround for this to try to have the controller read tilemap id's, or is there a completely different way to procedurally generate maps in GML 2 using tilemap functions that works better. Any info on this would be awesome!
 
I haven't done or learnt to make a procedural map generation but I have an idea that might give you some ideas?

You have a map creator object and that object gets created at one of the corners of the room. Lets say top left. And there are spaceholder objects on everytile you are going to place and it checks for the current position of itself and if there is collision, it will delete the colliding object and if there is no collision, it draws a ground tile with draw_sprite(currentx, currenty, sprite) and keeps going towards right with a speed of 1 pixel per step. When he gets outside the room, teleports to the second layer of the room and does the same thing.

But the thing is, currentx and currenty variables should be like x+7 -lets say your ground tiles are 8x8 sprites-

Here is my idea, if you can't get anything done, you might try something like this. Its probably not the efficient way to do it but yea :)
 
K

Kydrago

Guest
I haven't done or learnt to make a procedural map generation but I have an idea that might give you some ideas?

You have a map creator object and that object gets created at one of the corners of the room. Lets say top left. And there are spaceholder objects on everytile you are going to place and it checks for the current position of itself and if there is collision, it will delete the colliding object and if there is no collision, it draws a ground tile with draw_sprite(currentx, currenty, sprite) and keeps going towards right with a speed of 1 pixel per step. When he gets outside the room, teleports to the second layer of the room and does the same thing.

But the thing is, currentx and currenty variables should be like x+7 -lets say your ground tiles are 8x8 sprites-

Here is my idea, if you can't get anything done, you might try something like this. Its probably not the efficient way to do it but yea :)
That's essentially what the code I have from the tutorial does, except it starts in the center and moves randomly out. I guess just raw "create_sprite" might work as an "add_tile" replacement? I'm not even sure what "add_tile" actually does differently, but I'm using a grid data structure to govern the tile placement, and I'm not sure if trying to mess with "create_sprite" parameters is sloppy in that regard, or if the "tilemap_" functions make it obsolete.
 
That's essentially what the code I have from the tutorial does, except it starts in the center and moves randomly out. I guess just raw "create_sprite" might work as an "add_tile" replacement? I'm not even sure what "add_tile" actually does differently, but I'm using a grid data structure to govern the tile placement, and I'm not sure if trying to mess with "create_sprite" parameters is sloppy in that regard, or if the "tilemap_" functions make it obsolete.
"I guess just raw "create_sprite" might work as an "add_tile" replacement?"
I think so, you can check the GM:S 1.4's manual. And as I said, I haven't messed with tilemap or add_tile functions.
 
Top