Siolfor the Jackal
Member
Hey there,
I'm having a go a making a simple level editor, but I'm having an issue with the level import.
I'm loading in a simple .txt file and looping through to place wall objects, but it seems to be copying the first column and inserting it and I have no idea why.
At the moment, my text file starts like this in the top left corner:
But it in the game it displays this:
Which as you can see, is too many blocks. There should only be three on top, then one underneath, instead we get four and then two.
This is the script I am using to import the level:
I'm having a go a making a simple level editor, but I'm having an issue with the level import.
I'm loading in a simple .txt file and looping through to place wall objects, but it seems to be copying the first column and inserting it and I have no idea why.
At the moment, my text file starts like this in the top left corner:
Code:
WWW
W
Which as you can see, is too many blocks. There should only be three on top, then one underneath, instead we get four and then two.
This is the script I am using to import the level:
Code:
var i, j, _file, _grid, _height, _width, _arr, _str;
_grid = 16;
_height = round(room_height / _grid);
_width = round(room_width / _grid);
_file = file_text_open_read(working_directory + "levels\lvl_pac01.txt");
for(i = 0; i <= _height; i++)
{
_arr[i] = file_text_read_string(_file);
file_text_readln(_file);
}
file_text_close(_file);
for (i = 0; i <= _height; i++)
{
for (j = 0; j <= _width; j++)
{
_str = string_char_at(_arr[i], j);
if(_str == "W")
{
instance_create(j * _grid, i * _grid, obj_wall);
}
}
}