Game Development For Kongregate


Game Development For Kongregate

Recently, FSG released a new Android game (yay us!), called Circle Wars: When Shapes Attack. With that game out, and Idle Zoo in the middle stages of development I was left with a bit of time to, really, do anything. Sure, I’m helping RT with Idle Zoo a bit, but that work load is sparse right now until we really hammer down some design ideas. So I decided, might as well port Circle Wars to a web build, why not right? Now, we have used Kongregate as a platform before and things went great with Layin Pipe, but this time I wanted to get more involved with Kongregate and really dive in to their API (Layin Pipe didn’t use any of it). So, like any game developer, I took to Google to find some answers.

From my searches I was able to find some pretty good documentation to get started from here After doing the initial research, I needed to take a look at our current code base for CW and decide what Kongregate elements I wanted to add in. Again, this was a pretty simple process. We had in game achievements and they support “statistics”, we have an in game store, they support IAP. Things seemed to line up really well. One issue right away was that Kongregate recently stopped allowing rewarded videos ads which was a key element in our Anroid build. Not a show stopper by any means, at first we decided to simply remove the continue game feature as it is a little easier to play on web. That idea didn’t last, more on that later

Implementing the kong API appeared to be easy on the first go. I was able to get a build up and running rather quickly. I could see from the console (F12 in chrome) that I was connecting to their API and getting a user ID back. Next up I worked on adding the high score, again this was an easy process. Anytime a new highscore needed to be sumbitted we simply call Application.ExternalCall(“kongregate.stats.submit”, “Score”, VALUE); where VALUE is the actual number. I should also note, since we were porting the game from Android, and we have intentions to port to Apple eventually as well we developed a handler class that checks what platform we are on and issues commands to the correct class. Here’s an example of what I mean showing how we can submit a score to any platform just by calling addHighScore.

public void addHighScore(int score)
// Call IOS class

After the highscore work had completed, I began working on the statistics. This is where things took a turn, not because it was hard to implement on the Kongregate side, but because we had made some assumptions on the Android build that just didn’t work out well. Setting up the stats in kongregate was easy, we decided that all of our in game achievements could also be stats we send to Kongregate for potential badges. By doing this, it allowed all of our stats to either be a 0 or a 1 value. To set that up in our code we just needed to call Application.ExternalCall(“kongregate.stats.submit”, STAT, 1); where STAT matches the name we set up on Kongregate when we created our list of stats. I mentioned things took a turn here, one of the things Kongregate suggests is as soon as the game starts send them the current state of the statistics, this way if badges are introduced later on they can be awarded right away without having to complete the task a second time. So to do this, I simply have a list of all our achievements and iterate over them, any that are completed I pass a message to my handler to send the stat for that particular achievement, and I do this as soon as the main menu loads. Unfortunatly when I uploaded this to Kongregate to test, occasionally I’d get an error message pop up “kongregate is undefined“. Searching through my code I didn’t have any reference to a variable called “kongregate” it was a bit of a head scratcher for awhile. Eventually I commented out all the kongregate code and started adding pieces back in until I found the issue. Which turns out was a small blunder on my part, as it turned out when I took Kongregates suggestion of submitting the stats as soon as the game started I ended up calling it at about the same time the Kong API was being loaded. This is why it would sometimes work properly and other times fail.

Around this time I also realized the current way we handled our game state wouldn’t work on web nearly as well. The reason relates to a bug we identified with our Android build but found it to be more of an edge case. With the current code base, if we logged out of our google account and signed into a new account, the previous state would persist for the new user. With the web build, using a different browser would reset all progress and using different computers would also reset all progress. This is a big issue for a web game, so we started thinking of solutions. I wont go into all the details on how we ended up solving this, but I will make mention that our initial thought was we would retrieve the state of the statistics from Kongregate and use that to build our game state since it was assigned to a Kong ID, but all our research pointed to Kongregate not allowing us to retrieve stats but only submit them. The solution in the end was to build our own database and to use the built in Unity WWW class (yay MySQL and PHP)

After getting through our biggest road block we switched to implementing the IAP from Kongregate. Again we needed to decide how we wanted to handle this, and to us, the easiest solution seemed like the best. We decided to allow users to purchase our own game credits with Kongregate Kreds which in turn could be used to purchase skins, colors and new avatars in game. Again, setting this up was painless. From Kongregate we had to determine what price we wanted to charge, give it a description, and a name to reference. Then in our code base we had to call purchaseItems with a reference to which item, like the following

@”kongregate.mtx.purchaseItems([‘KONG_VARIABLE’], function(result)
var unityObject = kongregateUnitySupport.getUnityObject();

Testing this was also handled exceptionally well by Kongregate, because we are the uploader, Kongregate gives you the ability to try to purchase Kreds but don’t charge the account anything. After testing this a few different times everything seemed to be going well and it was time to submit our app for approval.

Submitting the app for approval was as simple as sending an e-mail to with the name of the game. I expected this process to take awhile, but that didn’t stop me from checking out database for any new entries. I was surprised when 2 days later I had seen 2 new entries show up in the database. Later that night I received my first response from a Kongregate team member and I was very surprised at the great feedback provided. I know Kongregate wants to make sure anything that gets uploaded using their API doesn’t effect their systems some how, so I expected feedback regarding those items, what I didn’t expect was some of the other items, such as suggestions on changes to the store UI to give a better user experience, suggested kreds prices and reasons why these could work better, suggestions on different game mechanics that could provide a better user experience and provide more potential revenue. I believe there were about 7 items of feedback given, each containing a few sentences as to reasoning. This was great, this amount of feedback to get on a game is outstanding. Not only were they helping me create a better game, but they also were helping themselves by giving suggestions that could push more sales and provide a better user experience. That’s a win win situation for sure. It was at this point I decided I wanted to address these issues as fast as possible, not just to get my game out there faster, but to show Kongregate that I fully understood their ideas and was able to implement them, as needed, with little to no risk of causing bugs somewhere else. After 1 more e-mail with even more suggestions, I was advised the game had no more technical issues and could be moved forward in the process.

That’s where this blog catches up to the present. Right now FSG is waiting for Circle Wars to be put up on Kongregate, part of this waiting is because, we aren’t sure if we want to wait until the end of the month to release the game as Kongregate runs a monthly contests for new games. As we sit, and wait for a couple questions to be answered, we are excited to have yet another game released on a different platform! Also, we are ecstatic to find that Kongregate such a great company to work with! They truly do give amazing support to Indie developers!


Leave a comment