code organisation best practices

0 favourites
  • 3 posts
From the Asset Store
5 levels with simple coding Source-code (.c3p) + HTML5 Exported
  • Hi everyone,

    I'm about to rewrite an old project in construct after a few years away from it, and wanted to organise code the cleanest possible. I found this interesting article, but unfortunately it seems not up to date: construct.net/en/blogs/skymen-13/optimal-write-events-construct-1049

    Is there a more up to date writing about this topic somewhere?

    Thanks

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I haven't seen anything up to date, but just from taking a glance at it a lot of principles probably still apply, it's just that in C3 there's better options to deal with it. For example, class inheritence is possible through custom actions. Here's roughly what I do:

    • Use families/custom actions where needed, which for example will apply to things like enemies.

    • Use functions where possible, especially if you suspect that you need to re-use the same functionality multiple times. E.g. saving the game can be triggered via autosave or via a button

    • Use eventsheets to group things that belong together, e.g. enemies

    • Then use groups to further divide the eventsheet up into the respective parts, e.g. I like to have a group called "enemies" and then have subgroups for each enemy like "enemies.goomba", "enemies.koopa",...

    • use local variables/instance variables/data objects in favor of global variables whereever possible. It's technically fine to have a lot of global vars, but often times it's not needed and it clutters the variable selection. So I'd reserve global variables for specific cases where it MUST be available globally and it's not worth putting into a data object (e.g. settings is a data object, not a bunch of global variables for each individual setting.

    • After a while you might notice certain parts of the code to "spaghettify", at least it always starts to happen in my projects eventually :D Especially when it's time to add a new feature. If you notice that, consider taking the time and refactor your code

  • Thanks for all these helpful tips!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)