[Request] Jump to label - Performance improvement

0 favourites
  • 10 posts
From the Asset Store
Firebase: Analytics, Dynamic Links, Remote Config, Performance, Crashlytics on Android, iOS & Web Browser
  • Hello everyone,

    I would like to suggest an addon which I have seen in RPG maker software so far. I think it might not be that easy to program it, but I think it`s worth it because this addon helps you to significantly improve the performance of your project.

    The addon should allow you to place labels inside the code of your event sheets and to call actions in other places which will make C2 jump to that label, which means that C2 skips the code between the 'Jump to label' and the 'Label' command and executes the code from the 'Label' position.

    How is that handy? I'll give you two examples (which are attached to this post):

    In example 1, C2 checks every 5 seconds which value the variable 'Sound_Variable' occupies and plays a sound corresponding of the variable's value. As the value reaches from 1 to 100, C2 will have to check 100 conditions, which certainly decreases the FPS, before it can create the object 'Blue'. Let's say that Sound_Variable has a value of 48, then C2 will still have to check condition 49 to 100 and determine them as false. By using the 'Jump to label' addon, this becomes avoidable:

    In example 2 you can see that there is a label called 'Label1' at the end of the 100 conditions and each condition contains a Jump to label action. Lets say that Sound_Variable=48 and so condition 48 is true, C2 will read the Jump to label1 action and skip all conditions from 49 to 100 and execute the code from the Label1 position on, then create the object 'Blue', which increases the FPS in comparison to example 1.

    Is it possible to create an addon like this?

  • First off, you could simplify all 100 sound checks into 1 event.

    Also check out the action "Wait for Signal" to see if that will do what you are trying to replicate.

  • System (Every 5 seconds) -> Play "Sound_Variable"

    *Make sure your variable is set to "text" and the value is just the name of the sound file, without the extension

  • Thanks for the answer!

    The event sheets I posted above were meant as examples to point out what kind of addon I'm asking for, I'm not actually using these event sheets in any of my games. Instead of checking for Sound_Variables and playing sounds, there could be any kind of action instead.

    I'm just disappointed by the fact that C2 has no option to abort the processing at certain positions in the event sheets, or to simply skip code to improve performance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • "I'm just disappointed by the fact that C2 has no option to abort the processing at certain positions in the event sheets, or to simply skip code to improve performance."

    It can, theres a ton of different ways.

    Nothing wrong with using Boolean variables either.

    Not to mention a ton of different ways to not have to repeat code, like play by name, etc.

  • this is basically a goto, which is something you really avoid in all programming languages because it makes code horrendously spaghetti like and hard to manage. You need to give a good use case to justify something like this, and you're example wasn't one, no example for goto's ever are. you could use the stop loop condition, or simply use a variable to choose the right sound. there are ways around goto's and goto's should be avoided.

  • Also against that, this would not be worth the effort, as the performance gain would be minimalist when you design your game with a good organisation (and also, that would actually break the organisation, which is a 100% no go in C2, where organising is really mandatory).As goto feels more like a cheap way to skip entire part of the code that will bite your hand when you will have to redesign some parts.

    To be fair, if you have performances issues due to that kind of problem (like the one you exposed, aka potential useless or redondant checks), rethink the design, in your case, you could either do:

    Play sound "Sound"&Sound_Variable (one action, no conditions, opposed to your 100 comparisons with the associated action play sound)

    Or have a list List="sound1,sound2,sound3" etc..

    Play sound tokenat(List, ",", Sound_Variable-1)

  • As already mentioned your original example doesn't need this feature. Also you can make events that skip un-necessary work - just put them in a sub-event to an event that checks if the work really needs to be done.

    Probably the best substitute for this feature is the existing Function object. That can be thought of as a go-to-event followed by a return-to-caller, supports parameters and recursion, and can go a long way to making your events more readable.

  • I guess I`ll have to find a way to work around the issues of my project then.

    It is possible to play a sound by name, which is an elegant way to shorten the code, but there is no such thing as 'create object by name', which forces me to use a lot of condition checks. Any idea on how to simplify this? Even when making use of functions, I'd still have to check for each value of the used variable and create objects according to these.

    (By the way, English isn't my native language, that's why my grammar might be awkward sometimes )

  • Ashley

    I would like to have "wait signal" SDK, to allow 3rd-party add/embed customize "wait signal" into actions.

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