I’m working on a little grid-based puzzle game and currently load the initial grid state by reading a table from a separate .lua file.
e.g. level1.lua containing something like,
gridTable={ {1, 2, 3, 4}, {4, 3, 2, 1} }
The above would be used to populate a 4x2 grid of objects with object ‘types’ between 1 and 4.
I would use a different file for each level in the game.
Firstly, is this generally a good way to handle level data and/or is there a better, ‘preferred’, way to do the same thing?
Assuming this is not a terrible plan to start with, what if I wanted to add further attributes to each item in the grid?
Would you recommend a straight forward extension as below:
gridTableA={ {{1, "a"}, {2, "b"}, {3, "c"}, {4, "d"}}, {{4, "d"}, {3, "c"}, {2, "b"}, {1, "a"}} }
or a more explicit:
gridTableB={ {{type=1, char="a"}, {type=2, char="b"}, {type=3, char="c"}, {type=4, char="d"}}, {{type=4, char="d"}, {type=3, char="c"}, {type=2, char="b"}, {type=1, char="a"}} }
Or, does that just come down to personal preference and readbility/manageability?
I am also planning to write a level editor to allow me to quickly set these up in a GUI.
I already know how to create the level editor on screen and manage the table data within the scene, but I’m not sure how I would output it to create the levelN.lua file.
I am loving using Corona and would be very grateful for any advice.
Thanks,
Jules.