D
Dragon Ferocity
Guest
Okay, I'm not exactly a noob here, but I can't figure out how to place tiles in the room using code.
Now before you post anything, I'm not looking for how to do tile collisions here, just how to draw tiles in a room.
If any of my code snippets are wrong below, please tell me.
I've looked through the manual, and it just confuses me.
To start with, I'm creating a new layer, and then creating a new tilemap on that new layer
Then, I'm wanting to draw multiple tiles in the room, and not place them by hand, because my levels need to be procedural generated.
Now here's where I get the info of the tilemap. At least i think that's what this code does? I'm really not sure what the point of this code is, but I saw it in the manual, so I figured I needed it.
Now this next piece of code is where the tiles are supposed to be place on the map that is created globaly.
xx is a global array that stores x values for each tile that I want to place, similarly yy is the y values.
The value of numRows is 300.
However, when I run this code, I get an error in the console
I literally have no idea what is wrong, or what I'm missing. The documentation doesn't help me either, and after searching around on the forums, I can't find any help for how to place tiles in a room using code. I can only find how to do tile collisions, which I don't want to do at this moment.
Please someone help me, and if there is a tutorial that explains how you actually place tiles in a room using code that would be marvelous.
PS, I also looked through the dungeon demo, it doesn't place tiles using code from what I could tell. If it did, I couldn't follow what the heck the code was doing.
Thanks,
Now before you post anything, I'm not looking for how to do tile collisions here, just how to draw tiles in a room.
If any of my code snippets are wrong below, please tell me.
I've looked through the manual, and it just confuses me.
To start with, I'm creating a new layer, and then creating a new tilemap on that new layer
Code:
GROUND_LAYER = layer_create(-10, "Ground_Tiles");
GROUND_LAYER_TILES = layer_tilemap_create(GROUND_LAYER, 0, 0, tl_dirt, room_width, room_height);
Now here's where I get the info of the tilemap. At least i think that's what this code does? I'm really not sure what the point of this code is, but I saw it in the manual, so I figured I needed it.
Code:
var dirtLayer = layer_get_id("Ground_Tiles");
var dirtMap = layer_tilemap_get_id(dirtLayer);
var dirtData = tilemap_get(dirtMap, 0, 0); //What does this even do? What's the point of this function?
Code:
for (var i = 0; i < numRows; i++) {
var numX = array_length_2d(xx, i);
for (var k = 0; k < numX; k++) {
tilemap_set_at_pixel(dirtMap, dirtData, xx[i, k], yy[i, k]);
}
}
The value of numRows is 300.
However, when I run this code, I get an error in the console
Code:
tilemap_get() - couldn't find specified tilemap
Code:
tilemap_set_at_pixel() - couldn't find specified tilemap
Please someone help me, and if there is a tutorial that explains how you actually place tiles in a room using code that would be marvelous.
PS, I also looked through the dungeon demo, it doesn't place tiles using code from what I could tell. If it did, I couldn't follow what the heck the code was doing.
Thanks,