S
Snayff
Guest
Afternoon all,
My end goal...
is to have an xls that holds all possible room designs, formatted in grids. Each cell in a grid contains a number which corresponds to the tile that needs to be placed. I would then "stitch" the rooms together to create one large map.
My current problem...
is with drawing the tiles to the Room. The code compiles and runs error free but nothing displays on the screen. I think it may be due to the _collisionLayer returning 0, though I am not sure why it has. That, or I am adding the tiles in the incorrect manner.
I have copied my code below. Please note that this uses placeholder values for now and the code will eventually be split out in to the discrete scripts.
Any help would be greatly appreciated!
-Snayff
My end goal...
is to have an xls that holds all possible room designs, formatted in grids. Each cell in a grid contains a number which corresponds to the tile that needs to be placed. I would then "stitch" the rooms together to create one large map.
My current problem...
is with drawing the tiles to the Room. The code compiles and runs error free but nothing displays on the screen. I think it may be due to the _collisionLayer returning 0, though I am not sure why it has. That, or I am adding the tiles in the incorrect manner.
I have copied my code below. Please note that this uses placeholder values for now and the code will eventually be split out in to the discrete scripts.
Any help would be greatly appreciated!
-Snayff
Code:
///@desc use data to create room
#macro EXIT 99
#macro EMPTY 0
#macro WALL 1
#macro WATER 2
#macro BRIDGE 3
#macro CRAWLER 4
var _y = 0;
var _x = 0;
var _tileCode = 0;
roomDesign[1] = ds_grid_create(10,10);
//loop Y
for (_y = 0; _y < 10; _y += 1) {
//loop X
for (_x = 0; _x < 10; _x += 1) {
_tileCode = 1;
ds_grid_set(roomDesign[1], _x, _y, _tileCode);
}
}
//var _tileCode = 0;// ref from data that dictates what tile to add
var _yCell = 0; // cell counter
var _xCell = 0; // cell counter
var _roomHeightInCells = ds_grid_height(roomDesign[1]); //how high is the room, in cells
var _roomWidthInCells = ds_grid_width(roomDesign[1]); // how wide is the room, in cells
var _collisionLayer = layer_get_id("COLLISION"); //get layer info
var _collisionTilemap = layer_tilemap_get_id(_collisionLayer); //get tilemap info
var _collisionTileData = tilemap_get(_collisionTilemap, 2,2); //get required tile info
//loop Y
for (_yCell = 0; _yCell < _roomHeightInCells; _yCell += 1) {
//loop X
for (_xCell = 0; _xCell < _roomWidthInCells; _xCell += 1) {
//take tile code from room design
_tileCode = ds_grid_get(roomDesign[1], _xCell,_yCell);
switch _tileCode {
case WALL :
tilemap_set(_collisionTilemap, _collisionTileData, (_xCell + 1) * TILESIZE, (_yCell + 1) * TILESIZE);
break;
}
}
}