Level Set-Up

What is the best way to set up multiple levels for a game? Currently, I have a separate lua file for each level. Is there an easier way to do multiple levels?

If it makes a difference, the levels use the same gameplay and interface, the only change is the amount/location of certain platforms [import]uid: 100403 topic_id: 22288 reply_id: 322288[/import]

You could do it in one file although personally I like a file for each level.

Are you modularizing your code? [import]uid: 52491 topic_id: 22288 reply_id: 88839[/import]

I would seriously consider using a data format, such as xml or json. Or even simpler, check out ICE (from the codebase)

There are several pitfalls to having multiple lua files that contain the same functions but just different object positions or similar.

  1. If you have all the same functions duplicated from lua file to lua file and you find a bug, you have to manually go into each one and fix the same bug numerous times.

  2. It makes doing updates and other things a tedious task.
    Look into ICE and data formats, then you can simply have one level file that contains all your levels and item/platform positions per level and simply re-initialize your variables on loading the next level then load your next level file.

It may seem complex or even hard right now, but I assure you once you put the time and effort into learning it , you will thank both me and yourself for doing it, and will never go back to having a lua file for each level ever again. [import]uid: 84637 topic_id: 22288 reply_id: 89306[/import]

I recently got some good advice as well here:

http://developer.anscamobile.com/forum/2012/02/13/how-organize-game-levels#_jmp0_

I was not able due to lack of skills to use the best approach but I am happy that I went for implementing modules in a very basic form, worth the effort. good luck! [import]uid: 109677 topic_id: 22288 reply_id: 90714[/import]