Construct 2 SDK - Advanced use

For developers using the Construct 2 Javascript SDK

Post » Tue Dec 20, 2011 11:40 am

Hi

Construct 2 evolve nicely and the tools seems to be quite pleasant to use. But I'm a bit lost with the features page.

Lately I create my own game engine, but for various reasons I'm always searching for something more easy to use.
Coming from a development side, I need to have a full access to every aspect of the engine.

I read somewhere that Construct 2 SDK would allow javascript to write plugins and behaviors.
  • Is javascript fast enough to drive all the game logic ?
  • Can you create OO plugins that interact with low level part of the engine ?
  • Does every features of Construct 2D are accessible from javascript ? (for example box2d)


Thanks for your answer.

MichalArmitage19822011-12-20 11:40:48
B
10
S
2
G
5
Posts: 14
Reputation: 3,194

Post » Tue Dec 20, 2011 1:37 pm

The SDK manual should answer some of those questions.
The plugin Physic is based on box2D.

You also can check out the custom plugins/behaviors.

I also recommand this blog's article with a lot of insights on C2.Kyatric2011-12-20 13:38:50
Moderator
B
154
S
53
G
28
Posts: 5,406
Reputation: 41,310

Post » Tue Dec 20, 2011 2:22 pm

Modern Javascript is compiled to machine code so it's definitely fast enough. I'm not sure what you mean by an "OO Plugin" (aren't all objects in C2 "OO"?) but they can definitely interact with the low level parts of the engine, mainly because Javascript doesn't support encapsulation. All the pre-supplied plugins and behaviors are written in the SDK as well, so all features in Construct 2 are exposed to the SDK.

You might also be interested in this blog post on Construct 2's architecture.Ashley2011-12-20 14:22:50
Scirra Founder
B
205
S
134
G
43
Posts: 17,478
Reputation: 112,193

Post » Sat Dec 24, 2011 2:39 am

Thanks for the answers.

I had a look at the provided links and the architecture looks really nice !

What I was meaning by OO design was strictly a manner of organizing my game objects, but if I correctly understand Javascript does not allow this feature the way I want and you must use a few tricks to do it correctly. It's a bit a mess but ok for me.

As an example, I know that one of the potential bottleneck of using Box2d is when you solve/pre-solve/post-solve the Contact Collision by Yourself.
- First, I don't know if using these callbacks are possible within the current architecture
- Second, isn't javascript a bit slow regarding to this task ? I ask only because I don't know much about this language and I'm nearly sure that I will have at least 50 or 100 collisions points to proceed each frames which is CPU intensive.
- Same think with the AI using Finite State Machine for every objects on every cycles.

I'm only asking this from a processing speed point of view. I know that HTML5 rendering still need a bit of power to talk about graphic speed right now.


Thanks for your support.
B
10
S
2
G
5
Posts: 14
Reputation: 3,194

Post » Wed Jan 18, 2012 9:17 pm

Well I did not get answers to these questions but since HTML5 is still a promise, I bet on scirra and construct 2 as my first tool in that new area. Time will tell me if I was right
In any cases I can still use it to build web stuff or simple things.
B
10
S
2
G
5
Posts: 14
Reputation: 3,194

Post » Wed Jan 18, 2012 9:46 pm

Hard questions to answer, as I don't believe anyone went for such advanced/specific use yet.

For the question about collisions, as I said previously the built-in physic behavior is based on box2D.
You can check this demo that shows quite a few elements on screen with physic behavior. It's perfectly fluid on my FF 9.0.1 on win7 (NVIDIA GeForce GTX 560 Ti).

So I guess JS via C2 sounds powerful enough on computation level (I'm not sure if the webGL rendering helps in any way with the computing of physic though).

And for the AI part, same thing I guess. I think I'm not knowleageable enough on this.
The furthier I went as for "AI"/computing is the pathfinder behavior and it has always appeared to work pretty good on my computer (I started it on XP with a dual core 2.5Gh and finished it on win7 with a quad core 3.5Ghz).

I guess if you really push it you will hit limitations, but hard to precisely tell you "you can do up to X collision at the second" for now 'cause it sounds it depends so much on the gear/OS/browsers/etc...

As you said, at worse you can always do "simpler" thing with C2 it is not totaly wasted money.

Keep us informed about your experimentations/results

Also moved to the SDK forum, it is less likely to drown answerless.Kyatric2012-01-18 21:50:11
Moderator
B
154
S
53
G
28
Posts: 5,406
Reputation: 41,310

Post » Wed Jan 18, 2012 9:51 pm

@Armitage1982, I'm not sure what your question was from your last post. Could you clarify what you were asking?

Javascript can be coded in an object oriented style if you choose, just because the language doesn't have the keyword 'class' doesn't mean you can't. And I already mentioned javascript is compiled to machine code these days so is pretty fast, although obviously not as good as C++. Performance varies depending on your machine and browser so you should just try stuff out to see if it's fast enough for your purposes.
Scirra Founder
B
205
S
134
G
43
Posts: 17,478
Reputation: 112,193

Post » Wed Jan 18, 2012 10:21 pm

I will !

Thanks for the replies.
I guess it all depends on the project. But if Construct 2 deliver his promesses then it will be a nice tool for fast prototyping and handy to quickly publish/update research on a game.

The physics demo you send me Kyatric is working smoothly too so who knows...
Box2d only compute things, actually you can use it without the need of any rendering stuff, so it will go as fast as the javascript engine goes. But it's always possible to create a huge array of games without relying on physics engine, so like you are saying it's not waisted money at all (and certainly not for that price). I can also probably learn a few things from C2 plugins source code too :)

As far as you keep a little room for the developer side of game making and avoid locking everything with too much UI tools, you can only enlarge your experienced users base (not that I am experienced at all but many have a rude approach of game maker tools. They think they can do everything... Yes but in 4 years ^^).

Thanks again, keep up good work ;)
B
10
S
2
G
5
Posts: 14
Reputation: 3,194

Post » Thu Jan 19, 2012 1:28 am

[QUOTE=Armitage1982] I'm nearly sure that I will have at least 50 or 100 collisions points to proceed each frames which is CPU intensive.[/QUOTE]

Umm... I am pretty sure somewhere in C2 I read that no more than 8 collisions points are recommended? And you want 50 to 100??? Am I misunderstanding what he is saying? O .o
B
46
S
8
G
6
Posts: 453
Reputation: 8,034

Post » Thu Jan 19, 2012 3:11 am

@VampyricalCurse: With the built-in behavior, the way things are coded yes, it's better to stick to 8 points.

Ashley had to code the physics behavior so it can be widely used, in many cases.
He had to make decisions to manage this.

But Armitage said he wanted to develop his own plugin based on box2D. So after all, maybe a specific implementation may help raising the possible number.
A plugin specificaly coded for a game could handle only issues of said-game.

I think in theory that makes it possible.
Now to see it actualy done is yet to be seen.
Moderator
B
154
S
53
G
28
Posts: 5,406
Reputation: 41,310

Next

Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests