tiles = {}
--tiles{{"tileNumber","xCoordinate", "yCoordinate"}}
tileNumber = 0
wHeight = love.graphics.getHeight()
wWidth = love.graphics.getWidth()
function tileCreate()
for x=0, wWidth, 50 do
for y=0, wHeight, 50 do
tiles[tileNumber][0] = tileNumber
tiles[tileNumber][1] = x
tiles[tileNumber][2] = y
tileNumber = tileNumber + 1
end
end
end
Yes, probably. If you do it the way you do it, you'd have not one but a whole lot of tables. First bracket would access "tiles" table, but the second bracket would access another table stored in "tiles[tileNumber]" slot. So you'll have master table plus one small table per every single tile.
It's not bad to have many tables (although having huge amounts of tiny tables is wasteful compared to few large tables). In fact, most programs are built around storing all information in variety of tables, making them plentiful. If you need a table for any reason - just go ahead and use one. The single consideration you need to know about it is that tables you no longer grip to become garbage and contribute to garbage collector processing payload, making memory sweeps take more time, so don't just create and discard them in huge numbers, try reusing them. If you want to be really technical, there are other two: B) tables have minimum memory footprint of having enough space allocated to store 4 integer-keyed values and 4 arbitrary-keyed values i.e. total 8 slots, 4 in array and 4 in hashtable, so creating tables with only 1 or 2 values stored in them is wasteful, and C) each table access takes some time, so data access over longer chain of brackets and dots will take more time. But those two are nothing you should be actually worried about because their impact is usually minuscule.
tiles = {}
--tiles{{"tileNumber","xCoordinate", "yCoordinate"}}
tileNumber = 0
wHeight = love.graphics.getHeight()
wWidth = love.graphics.getWidth()
function tileCreate()
for x=0, wWidth, 50 do
for y=0, wHeight, 50 do
tiles[tileNumber] = {} -- this line, otherwise the below 3 lines will error.
tiles[tileNumber][0] = tileNumber
tiles[tileNumber][1] = x
tiles[tileNumber][2] = y
tileNumber = tileNumber + 1
end
end
end
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.