Lua Game Architecture

Hi!

I need to ask you guys something which bothers me. As you all know a game matures and gets bigger while developing it. New ideas, removed and added functions, some testing stuff…

After a short time it all feels unstructured and I am asking myself “what the hell, that should be easier?”. I know of entity component systems but I don’t only mean that. I also mean something like folder structure, separation of logic and view and so on. I know that we are developing games and no enterprise applications but I may think that some of the stuff which is done on enterprise application development can also be done on game development. But maybe I don’t know that :smiley:

I need a good architecture and structure for future games.

Right now I am doing this:

  • Backend (Folder)
  • ads (Folder)
    • Admob.lua
  • npc (Folder)
    • enemy.lua (all of the enemylogic is here)
    • merchant.lua (…)
  • player (Folder)
    • player.lua (create a player with all his attributes, like inventar, …)
  • utils (Folder - which has Utilitystuff for “backend”)
  • Frontend (Folder)
  • IntroScene (Folder)
    • IntroScene.lua
  • GameScene (Folder)
    • GameScene.lua (here the cocosstudio-file is loaded and some initializationstuff from the backend is called)
    • InterfaceInitialization.lua (the buttons and other stuff which is in the cocosstudio-file is mapped to function-callbacks)
    • LayerHandling.lua (for example the GameScene has Layers (some are visible, some are hidden) this stuff is in this file)
  • SettingsScene (Folder)
    • SettingsScene.lua (same as above)
  • utils (Folder - which has Utilitystuff for “frontend”)
  • main.lua (which calls a Scene)

What do you say about this approach? Is it over the top?

How would you for example save data when switching the Scenes. Would you save it in a global lua table? Should I design everything as a lua class or should I just jump from function to function. Meh.

I think I have a lot of questions but right now I can’t formulate these :smiley:

Well, let’s see what you are answering ^^