Integrating APIs

0 favourites
  • 8 posts
  • As you might know, there are (besides the big players like steam) some open platforms for casual/indie games. One of them is Kongregate

    They offer an relatively easy to use API, supporting ActionScript 2/3 and Javascript.

    Have a look at the Javascript API. How could it be integrated to C2?

    Following the link, you can see that they also offer a html shell to make things easier. You need to embed the game in order to use the shell, of course. Does this work with C2?

    In addition, there's the server-side JSON API, used for payment, high scores, badge feeds, etc. Again, how would that be integrated?

    I know, that the API works for non-flash games, as I have tested several Unity games there. But I'm an absolute beginner when it comes to Javascript/html5.

  • Anyone?

    I'm not looking for a complete solution to this problem, just a description of the way it would have to be done, maybe with some keywords that I can then google for. Or a statement that it isn't possible.

  • I'm not a kongregate user, so I don't really know how it works on their site.

    From what I can see, I'd say you would have to modify the index.html file of an exported project and add the line:

    <script src='http://www.kongregate.com/javascripts/kongregate_api.js'></script>

    With the others "scripts" lines.

    That would allow the API to be available to your application.

    The tricky part would be using

    // Load the API
    var kongregate;
    kongregateAPI.loadAPI(onComplete);
    
    // Callback function
    function onComplete(){
      // Set the global kongregate API object
      kongregate = kongregateAPI.getAPI();
    }

    That initiates the kongregate's API in conjunction with the already present code that launches the C2 runtime in index.html.

    // Start the Construct 2 project running on window load.
            jQuery(document).ready(function ()
            {
                // Create new runtime using the c2canvas
                  ?cr.createRuntime("c2canvas");
            });
    

    Try to put the kongregate's code prior to C2's.

    This might work, or you might end up with an issue because jQuery isn't used for kongregate. I don't really know at this point.

    A plugin would then be the interface calling the JS kogregate's API functions according to C2 events. (this is pretty much the same as using jQuery functions in a plugin, I think the subject is evoked in C2's sdk).

    On the other hand, the server-side API is really simple. Just throw ajax calls at the urls indicated. You don't even need another plugin for that and can handle it through events pretty easily.

    JS is pretty straight forward to get used to (especially if you coded in other languages).

    Just check out MDN JS guide for starters.

    Hope it helps.

  • Thank you very much, Kya, that helps a lot. I always try to solve issues, but in cases like that, I need a starting point. You just gave me one :)

  • Most javascript APIs should be straightforward to throw in to a plugin. Things like this we would do ourselves, but we have so much other work to do it will probably be put off for a long time until we get round to it. If third party plugin developers can pick up little jobs like this, it's really helpful to us and frees us up for other editor work and the like. Still, if nobody does as I said we'll eventually try to get round to it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I can probably pick this up, but I can only work on stuff during weekdays. I still have to finish my bouncing ball behavior, fix that bug with the turret object (as well as implement the stuff that is missing and optimizing it), do the docs for all of them (those will probably have to wait a bit) and crank out a couple tutorials.

    Funny how I'm overworked with scirra stuff, and I don't even work there :P

  • That would be awesome!

    In the meantime, while you are optimizing your current plugins, I will start teaching myself javascript and test my capabilities. Kyatrics online version of the C2 SDK documentation is very useful, and from what I see it seems to be a straightforward adaptation of the C++ SDK for CC, so it shouldn't be too difficult.

    Then again, learning is much harder as you get older... :D

  • Kyatrics online version of the C2 SDK documentation is very useful, and from what I see it seems to be a straightforward adaptation of the C++ SDK for CC, so it shouldn't be too difficult.

    Then again, learning is much harder as you get older... :D

    Beware though, the HTML version of the sdk is not up to date.

    Be sure to dld Ashley's SDK package.

    But yes, learning gets hard, but JS appeared quite simple, and when oriented at plugin developement, it is almost "follow the guide" :)

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