Code Organization Issue

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

    I'm having an organization problem with my more complex projects on C2. As they start to get more complex and bigger I start having trouble to maintain my code/events.

    I always feel like i have to create more event sheets to code simple object rotation/positioning/effects/game mechanics, etc... , and when I later need to review them again, I get lost.

    For example, and I don't mean to compare Unity and C2, but when i use Unity for my projects I feel like I can easily find and understand what I'm reading. I thinks it's because each object has script components, and that makes code much easier to find and maintain. If I get back to a script file I haven't touched for a while I can easily continue with it. I don't understand why, but this is harder to do in C2, at least for me.

    Do you guys have any tips on organization ? Cuz it forces me to switch projects, and split them into simpler modular projects that i can use later.

  • Hey Baionera, C2 has a group function that enables you to group pieces of code into several components which you can label yourself.

    Or you could make a code that's super messy but still play well. For example, check out the game in my siggy. Being my first game when I barely knew how to use C2, the code is an absolute mess however I'd say it still plays well; well maybe not well but it plays the way it's supposed to.

  • I use a 'branching tree' Structure for the most part.

    Example:

    If gameMode="action"

    • Controls code
    • Enemy AI
    • Etc

    If gameMode="cinema"

    • If scene="intro"

    If gameMode="menu"

    Coding this way makes it easy to find what I'm looking for, as the base events are like categories and each subevent becomes more specific.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • One approach to also take is to split off different components into their own event sheets. Such as one for enemy AI, one for HUD functions, etc. Then make a "Main" event sheet that includes the rest and only includes vital/startup functions.

  • There's always bookmarks you can use, also groups (groups within groups), and comments. I find different too many event sheets per layout hard to work with, So I mainly use one per layout then open or close groups instead depending on what layout.

    Usually i have all controls related stuff in one group, UI stuff in one group, Other logic/game events and stuff in other groups, And then using subgroups for specific things. By deactivating unused groups you can save a lot of processing power as well. The less events the engine has to go through each tick the better.

    Another good way I find really useful for organizing is using functions. Instead of having a HUGE list of sub- events, conditions and actions and I call functions instead. Functions you can name properly, and find more easily for specific things.

    For example:

    On mousebutton down:

    ---> Call function: CharShoot

    ---> Call function: CharSound

    ---> Call function: UpdateBullets

    ---> Call function: CharAnimation

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