Why are Plugins Faster then Construct2 ?

0 favourites
  • 3 posts
  • For example at Pathfinding or creating random generated terrain.

    Why is it that these things are best done with plugins that use straight up Javascript instead of using Construct2 directly?

    Is Construct2 not converted into JavaScript? So what are the reasons that it is slower?

  • Schoening : I suppose that when you say "Why is it that these things are best done with plugins that use straight up Javascript instead of using Construct2 directly?", you mean for example doing the Pathfinding with events inside C2.

    As a plugin maker, I can explain some reasons, perhaps Ashley is going to add a few things.

    • C2 is in fact a big game framework, and leike every game framework, you have a main gameLoop(), which contains the various events, and that one is run at each step, 60 times per seconds (in C2, those are the events listed inside the editor, that you add with the mouse).
    • when you use events, you need to conform to C2's mode of working, which is event-based (a paradigm of programming, you can also see reactive programming in the litterature).
    • some algorithm are easier dealt with a functionnal or modal way of developping (something you can do with Javascript, C/C++, Java, etc...)
    • Ashley has baked a lot of checks, memory reuse, smart tricks and the like inside C2's engine. That means that every event you add inside the loop in the editor is going to be efficient regarding the use of graphics, sounds, browser access, memory, etc... However, in a plugin, you often deal with pure mathematic problem (like crawling a graph => pathfinding, face recognition => decisions trees, etc...). Those "mathematical" problems doesn't need all teh tools and gear needed for media handling that C2 provide, but they pass them anyway if you use events.
    • So if you have a JS plugin, you can defer small specialized work to a small JS function, that bypass C2 workline, or in some case (webworkers and all that) can execute parallel to C2's main thread.

    TL;DR : C2 handle all the gamefield that you can leverage in a JS plugin where you concentrate on only a small problem, helping you being faster in that particular case.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Pode

    Thank you for the quick reply :)

    I was thinking along those lines too.

    Construct2 has to take far more things into account and thus the exported code is probably a lot more complex then my own simple JavaScript code would be.

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