How do I optimize my event sheet?

0 favourites
  • 6 posts
From the Asset Store
14 amazing sound files of game events like Level Ups, Level Completes, object spawn, object taking etc.
  • Hey everybody,

    Now I have this question floating in my mind. How to optimise events. In C2 events are read from top to bottom. Yes, I did my research ;)

    What is the impact to performance and/or efficient if events aren’t in an optimised order?

    Example:

    Let’s say I have 3500 events and I have organised them by folders. All player events are in the folder called “Player”, all enemy events are in “Enemy” and so forth.

      “Player” root folder
        “initialisation” subfolder “controls” subfolder “animations subfolder
      “Enemy” root folder
        “initialisation” subfolder “AI” subfolder “animations subfolder
      “Enviroments” root folder
        “trees” subfolder “animals” subfolder

    Next, on start of layout I want to create player object.

      “Player” root folder
        “initialisation” subfolder on start of layout: create “player” sprite object at X/Y. “controls” subfolder “animations subfolder
      “Enemy” root folder
        “initialisation” subfolder “AI” subfolder “animations subfolder
      “Enviroments” root folder
        “trees” subfolder “animals” subfolder

    Then I want to create some enemies and some trees, also on start of layout:

      “Player” root folder
        “initialisation” subfolder start of layout: create “player” sprite object at X/Y. “controls” subfolder “animations subfolder
      “Enemy” root folder
        “initialisation” subfolder on start of layout: create “enemy” sprite object at X/Y. “AI” subfolder “animations subfolder
      “Enviroments” root folder
        “trees” subfolder on start of layout: create “tree” sprite object at X/Y. “animals” subfolder

    Question: in this example, are all those on start of layout -events fired on start of layout, even though some of them are very bottom in events order? To me the answer is yes but could there be an issue of some kind if there are 3000+ events between the first on start of layout -event and the second? Should I do something like this instead:

      “Root” folder
        “initialisation” root folder on start of layout: create “player” sprite object at X/Y. on start of layout: create “enemy” sprite object at X/Y. on start of layout: create “tree” sprite object at X/Y.
      “Player” root folder
        “initialisation” subfolder “controls” subfolder “animations subfolder
      “Enemy” root folder
        “initialisation” subfolder “AI” subfolder “animations subfolder
      “Enviroments” root folder
        “trees” subfolder “animals” subfolder

    Personally I don’t want to use this method because I really want to organise my events by putting every player related stuff in “Player” folder and so on. BUT if there indeed are some performance issue or similar thing, then I guess I have no way around but to do like I described above.

    If someone has a tip or two to offer, feel free to do so ^^

    -M-

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • yes, all of those On start of layout triggers are fired on the start of the layout, and I'm sure they all fired at the same time because they are triggers. Triggers don't follow the "top to bottom" rule, the actions in the triggers are read when the event that fired the trigger happen (in this case, start of layout)

  • yes, all of those On start of layout triggers are fired on the start of the layout, and I'm sure they all fired at the same time because they are triggers. Triggers don't follow the "top to bottom" rule, the actions in the triggers are read when the event that fired the trigger happen (in this case, start of layout)

    In fact, they follow the top to bottom rule, but within the moment the event is trigger. In your example Mithrill, you can let the "On start of layout" events in the folders they belong, that is not going to cause any problem. The first will be triggered, then once all its actions are done, the second will etc... I share your opinion on the matter : That clearly will be more readable.

  • Use the Function object and make functions with it.

    Have the root foler execute a function "InitPlayer" that is situated in the Player "folder", and a function "initEnemy" situated in the Enemy folder, and so on.

    Don't hesitate to add prefixes to the names of your functions to "situate" your functions (for example Player related functions could start with "PLA_").

    If you have 3000 events, you have possibly room to actually refactor and simplify a lot of your code and using the Function object could be the first thing to do on that track.

  • Also, as a good development practice, try to get the same contextual events separated within their own sheet (if by "folder" you didnt mean event group, but meant event sheet already, my bad then).

    With your example, you could have a System ("root"), Player, Enemy and Environment sheet, including them wherever is needed.

    About the order of execution, don't worry, as long as they are logical for what you wanted. The same thing happens in programming: each compiler/intrepeter knows when to execute something.

  • Thank you everyone for charing your tips :)

    Daggio,@Bro7hers, looks like my research about events sheets failed me :/ I had completely forgot about those trigger events and how they are executed.

    Kyatric, this function method sounds like a good option. Currently I really need to find a way to optimise my events.

    Cassianno, yes, I did mean event groups so my bad -_- About your tip, personally I don't want to separate my events into many event sheets. Too much hassle and to me it's hard to keep track of what is where. This is completely personal opinion of course :) I like to use groups instead.

    Another question rise from back of my head: I'm using same group structure as in my first post. Lets pretend that I have a boolean variable called "isActive" in group Enemy/AI.

    Just for demonstration,

    distance: player, enemy less than 50 > set enemy.isActive = true

    when that boolean variable "isActive" is true > set enemy angle to player.X/Y.

    else

    distance: player, enemy greater than 50 > set enemy.isActive = false

    Boolean variable "isActive" is false > set enemy angle to self.X/Y.

    What are the benefits if I disable that Enemy/AI group when boolean "isActive" = false? Because I don't see any reason for C2 to check those events in that group if Boolean isn't true in the first place.

    I was thinking something like this:

    distance: player, enemy less than 50 > set group Enemy/AI > enabled and set enemy.isActive = true

    Boolean variable "isActive" is true > set enemy angle to player.X/Y.

    else

    distance: player, enemy greater than 50 > set enemy.isActive = false

    Boolean variable "isActive" is false > set enemy angle to self.X/Y, and set group Enemy/AI > disabled.

    really quick and dirty example and I hope everyone will understand :)

    What I understand about C2, is that it will check events in every event groups which are active (obviously). If I have that 3000+ events, I think it's not really beneficial to check events from every group if those events aren't used. Using that example above: if group Enemy/AI is active, C2 will check that group and that boolean. Then C2 will run the events depending of the boolean state. BUT if that group is disabled, then C2 will skip it and theoretically save some recourses.

    If I'm completely wrong, please correct me. I really want to understand how to optimise events and how C2 is handling things.

    -M-

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