Structuring/organizing code

Hi Ansca Community

I have a couple of questions and things I need help to. And instead of creating a topic for each question, I have collected them here.

A question related to what the best way to code a game is - organizing and so on. With all the ways of doing it - I have been confused.
And a question (maybe related to the first question - organizing vice) what the best way to restart a level without making a lot of “go between” scenes with Director? :slight_smile:

  1. I have in a long time been accustomed to put all my code into a function, and when I saw the sample code - Ghost vs. Monsters By the BeeBes, I saw that it was programmed with a lot of small functions, which is then called by a gameInit function in the end.
    My question is: What is the best way to organize and program a game, with ONE large function with all the code/game logic, (maybe the “new” function in Director) or more smaller functions with the logic which is then called in a function in the end (like the gameInit in Ghost Vs. Monsters)?
    Thank you very much for the help in advance. I look forward to your answer!

Best regards

Me :slight_smile: [import]uid: 122802 topic_id: 26623 reply_id: 326623[/import]

Bump… I appreciate your help :slight_smile: [import]uid: 122802 topic_id: 26623 reply_id: 108096[/import]

If using Storyboard you can purge and reload a scene without a go-between. With director you could use one scene and a variable to choose which scene to reset. (Though asking about this in Director sub forum you may get more input on that.)

Your other question RE functions is really about what you like personally. I find small functions the most convenient and easiest to manage however if you prefer one big one and that works for what you want to do there is no reason not to do it that way.

Peach :slight_smile: [import]uid: 52491 topic_id: 26623 reply_id: 108625[/import]

Hi Peach

Thank you very much for your response. I appreciate that you shared your opinion on how to organize the code. Thank you [import]uid: 122802 topic_id: 26623 reply_id: 109400[/import]