Scirra cog

About Us

We're a London based startup that develops Construct 2, software that lets you make your own computer games!

Archives

Browse all our blog posts

Latest Blog Entries

We love brains!

Join us! Joiiinnn ussss! Mooooree brains!

Construct 2's architecture

by Ashley | 13th, October 2011

We've had some excellent plugins and behaviors developed by some of our forum users recently, like Kyatric's pathfinding behavior and others. Construct 2 can be extended with Javascript and this makes for some really exciting possibilities. However, this is just the start: we've got much bigger plans for allowing plugin developers to expand Construct 2! In this post, I'll outline Construct 2's architecture, and what this can allow for in future.

Construct 2 has a highly modular design. The editor actually is a sort of empty shell of buttons and windows that doesn't do much on its own. The substance of functionality comes from exporters and plugins. These make Construct 2 extensible by both ourselves and third party developers. It's designed to adapt to the changing world of technology, making it future-proof against whatever happens in the future. Let's see how this is done.

The editor

The Construct 2 game editor
The Construct 2 Editor, the start point for making games!

The Construct 2 editor itself contains your project, and of course all the interface parts necessary to edit it. It's written in C++. However, it's agnostic towards the exporter technology. The editor is designed to have no idea about what you're exporting your project to. We only support HTML5 right now, but in future we might want to write an exporter for WebGL, OpenGL, iOS native, Android native, XBox or something not yet even invented. When the time comes, we can do this without a single change to the editor! This is because the editor loads exporters, which are developed in isolation and compiled as DLLs.

Right now we only have a HTML5 exporter, so we're describing Construct 2 as a HTML5 game creator. However, it's perfectly possible that more exporters are written in future. I should add - we're a very small team here and we're already extremely busy with the HTML5 features! We're not planning any new exporters for the near future. However, the fact we have this capability is an important part of our long-term plans.

Exporters

The Construct 2 HTML5 exporter
The HTML5 exporter is the first exporter by Scirra

So what exactly is an exporter in Construct 2? Exporters have two tasks:
1. Find and load plugins, and tell the editor about them.
2. Convert your project to a platform (in this case, HTML5).

Plugins for the HTML5 exporter are written in javascript, so developers can extend Construct 2 with nothing but a text editor. There's no need to buy expensive development tools. Plugins consist of an edit-time part, that tells the editor what the plugin can do (its actions, conditions etc.), and a run-time part, that actually does the work in the HTML5 web page. The HTML5 exporter uses Google's V8 javascript engine to understand the edit-time part. This way, the exporter loads a javascript plugin and tells the editor about it.

When you click preview or export, the HTML5 exporter converts your project in to HTML, javascript and PNG images. It generates all the necessary code for your game to play on a web page. It also launches a local HTTP server to work around browser security restrictions.

So the HTML5 exporter has the Google V8 javascript engine and a HTTP server built in - and the editor has no idea. The editor says "here's a project, preview it" and doesn't know what happens next! All the previewing happens inside the HTML5 exporter. So we can swap or change any of these technologies without worrying if we'll break the editor.

Plugins

Construct 2 game maker plugins and extensions
Plugin a plugin!

Exporters tell the editor which plugins are available. Note that the editor does not load any plugins itself. It is the exporter which loads plugins, and tells the editor about them on the plugin's behalf. This may sound like a long winded way of doing it, but it means the way plugins are written is unimportant. They could be written in Javascript, Python, C++, C#, or some custom system. As long as the exporter can load and understand them, it's fine - the editor doesn't need to know. The HTML5 exporter therefore uses javascript so it's the same as the runtime part of the plugin, which must be javascript to work in a browser.

Why is this useful? If someone wanted to write an XBox exporter, it would probably need to load C# plugins. They can't modify the editor - we are in charge of that. However, they can write their own C# plugin loader in the exporter, and have plugins working the way they want them to. We never have to have anything to do with it!

Total modularity

Some game editors don't have plugin systems - everything's built in to the editor, making the editor a giant monolith that does everything. This is bad for two reasons. Firstly, unless the editor is open source, nobody can improve it by writing plugins. Secondly, it's probably very difficult for the developers themselves. One gigantic lump of code is harder to manage than smaller components that talk to each other, each with a very clearly defined purpose.

Some other tools also have, or are planning, a monolithic editor with a plugin system added later. This to me isn't really a plugin system. You've already got a monolith, and it relegates third party plugins to second-class citizens. It usually means plugin developers can only use a limited set of features that get added with the plugin system, while the built-in features have "special access" which you can't reproduce with third party plugins. This means sometimes plugin developers with exciting ideas find they simply aren't able to do what they wanted. How disappointing!

Only the system object in Construct 2 is built in, and out of necessity (it genuinely requires special access). Every single other object is written as a plugin, using the same features available to third parties. Even the Sprite plugin - the cornerstone of almost every game - is coded out in its own bit of javascript just like every other plugin. Since many important features of Construct 2 are coded in the plugin SDK, it requires that the SDK to be extremely powerful, and that power is shared with all plugin developers. It's certainly not an afterthought: extensibility has been designed in from the start.

Future plans

Game making in the future
TO THE FUUUUTUUUURRRREEEEEEEE!

As I mentioned, we're hard at work on our HTML5 features right now. However, one of our long term plans is the possibility of releasing an Exporter Development Kit (EDK) in the long term future. (I must emphasise that's the long term future - please don't get too excited just yet!) This would open up Construct 2 to having third party developers writing exporters for Construct 2. Enterprising developers could even make a business of writing, and separately selling, their exporters, and it means you get to run your games on even more platforms. However, it's a big and complicated thing to co-ordinate, so it's just part of our distant-future plans right now. It does mean though that plugin developers will have much more freedom to take Construct 2 where they want.

Construct 2 HTML5 game creator logo

Overall, I think it's fair to say Construct 2 is one of the most modular, and most friendly to plugin developers, of the game editors on the market. In future, we hope plugin developers have the same access to writing both exporters and plugins that we have as official Scirra developers. This could allow for a great deal of possibilities that we haven't even realised ourselves yet - so we'll just have to wait and see what happens!

Do you fancy having a go at extending Construct 2? Check out the Javascript Plugin & Behavior SDK, which includes documentation. We've also got a new forum to share third party plugins and behaviors.

Now follow us and share this

Tags:

Comments

4
alspal 22.5k rep

Interesting writeup, I like how you're approaching Construct 2. I just wish you were a big enough company to have more people making exporters/plugins fulltime though!

Thursday, October 13, 2011 at 1:38:40 PM
4
FireLight 2,607 rep

The SDK is really great to work with and i really like the plans you have with the modularity and exporters.

For the "most friendly to plugin developers" quote i 90% agree with that. All my plugins had to be remade after a SDK change and i also have a few SDK features i need but in fairness that is just down to the fact it's early in development.

There is probably a load of important things to be done at the moment and it's still beta stages really. Later down the line though i am sure that will be 100% true as the SDK and program get a lot more stable.

You have done a really amazing job so far though and i really like the plans for the program, keep up the great work. :D

Thursday, October 13, 2011 at 3:31:47 PM
3
Jailson 12.9k rep

Nice! I was really wondering how to add more behaviours, and pathfinder was exactly I was looking for!

This post was very useful to me!

Thanks!

Thursday, October 13, 2011 at 4:11:59 PM
2
mrsponkie 4,018 rep

I love C2 !

Thursday, October 13, 2011 at 5:13:07 PM
1
tavitooo 5,083 rep

Muchas gracias..!!

Saludos

Thursday, October 13, 2011 at 5:28:20 PM
1
CoolCatGames 3,570 rep

Nice editor.

Looking forward to the future.

Thursday, October 13, 2011 at 7:12:51 PM
3
Counterfeit 5,220 rep

I like the way Construct 2 is to be going! I really respect the work of you and Tom!

Thursday, October 13, 2011 at 7:32:29 PM
1
Trevor10 4,161 rep

Since an EDK is not available does that mean it's currently not possible to write an exporter?

Thursday, October 13, 2011 at 11:17:45 PM
2
Ashley 193.7k rep

@Trevor10, not yet, as the post says it's part of our plans for the long-term future.

Friday, October 14, 2011 at 1:19:22 PM
0
wilfryed 4,737 rep

Exporters sound really interesting, furthermore for iOS.

I stay tuned !

Monday, October 24, 2011 at 3:49:24 AM
0
Bigheti 17.0k rep

I used Game Maker software, but when I met the C2 change was immediate. And the perspectives presented here are promising for this software. Let's wait for the time tell us about the excellence of the C2.

Thursday, December 01, 2011 at 4:38:06 PM
0
Kiyoshi 13.3k rep

Ashley since everything is so modular i highly recommend you to get more people on your team, specially programmers. Work will only get bigger and bigger. Not only bug fixing but to work on things like the image editor and parallel things like new exporters, while the EDK is not released. Of course managing a team is hard but it's a necessity if C2 is to be the best 2D game IDE. I say this in hope of C2 one day becoming the Unity of 2D games (Perfectly possible). And i intend to help however i can to reach that goal.

Tuesday, December 20, 2011 at 9:33:26 PM
0
Ashley 193.7k rep

@Kiyoshi, unfortunately we can't afford additional programmers right now (hopefully we will in future though!). On the other hand, the modular architecture is already working out really well though - we've got something like 50 plugins/behaviors by 3rd party devs already!

Tuesday, December 20, 2011 at 9:39:20 PM
0
Kiyoshi 13.3k rep

Well then i hope you guys get rich soon then :D
I too am making a plugin based on tween.js and hope to release it soon :) I'm not very good at JS but i'll do my best.

Tuesday, December 20, 2011 at 10:01:37 PM
0
GamerGon 5,614 rep

As clear as water :)

Tuesday, May 22, 2012 at 5:33:16 AM

Leave a comment

Everyone is welcome to leave their thoughts! Register a new account or login.