I'm writing a block breakout game and I'm having trouble loading the templates I've made for it... I'm really just wondering if anyone can tell me what I'm doing wrong here:
Code: Select all
function LoadMap(map)
local row_num = 0
local column_num = 0
for line in io.lines(map) do
row_num = row_num + 1
for j = 1, line:len() do
column_num = column_num + 1
NewBlock(row_num,column_num,string.sub(line, j))
end
column_num = 0
end
end
The variables for the function 'NewBlock' are Row, Column, and Health. Each line of the template file is a row, each character of the lines are the columns, and the value of each character is the health of the block... This is what the templates look like:
Code: Select all
0000000000000000
0000000000000000
0000000000000000
5555555555555555
0112344554432110
0112233333322110
0012222222222100
0001111111111000
If anyone could lend me a hand I would be very grateful. The rest of the game is completely done... I just need to read from the templates and debug the blocks' collisions to finish it.