@toxic_lj i tried reimplementing this using the tile util extension, but it’s still pretty complicated. here’s that code:
the issue is that the connection blocks in the tile-util extension are bi-directional which doesn’t work for dungeons that are made up of grids of connected rooms… you end up having to create “Even” and “Odd” connections to prevent rooms from accidentally overriding each other’s connections.
I think I should probably just make an extension that is explicitly for connecting tilemaps in a grid. that would certainly make zelda-like games like this one easier to author.
@toxic_lj in that sample code i gave, it’s actually already doing that. the array of room types is actually a double array, and each index represents all of the possible rooms for that type. all you have to do is add more rooms to each of those arrays
@toxic_lj what you want to do is change the tilemap when the player picks up a coin or interacts with a button. typically, i do it like this:
when the tilemap loads, create a coin sprite on top of each of the coin tiles in my map
use the “cover tile” block from the arcade-tile-util extension to cover those tiles with floor tiles
inside of the “on player overlap coin” event, set the tile underneath the coin to be the floor tile. this way, the coin won’t get respawned by step 1 when the map is reloaded
well the thing is… I was using your “map of tilemaps” and it seems that no matter what it resets the maps when you re-enter them. how would you do it then?
thanks! okay, this should be pretty easy to fix. be sure to make a backup of your project before making the changes i’m about to suggest just in case!
so the reason this isn’t working right now is because the SetRoomTo function returns a fresh map every time a room is loaded. we want to keep the same maps around in an array so that they don’t keep getting reset. our strategy is going to be to convert the TheMap array in your project into a double array of TileMaps instead of a double array of room kinds.
first, let’s convert your SetRoomMap function into a new function called GetRoomMap that returns the tilemap for each roomkind instead of setting the current tilemap. it should be basically the same function, but replace all of the set tilemap to blocks with return blocks, like I did for the first roomkind in this screenshot:
then, inside of your GenerateMap function, instead of filling the TheMap array with room kinds, let’s fill it with tilemaps instead. in the line where you are adding the result of FigureOutRoomType to the array, instead pass the output of that function into your new GetRoomMap function
finally, in your LoadRoomDirection function, you’ll want to call the set tilemap to block directly instead of calling SetRoom. you also will want to move the InRoom = false block from SetRoom into this function as well: