Kongregate API for Java
Current version of API is 0.3, it allows you to:
- deploy your Java game on Kongregate easily
- check if player have needed version of Java, show popup if not
- simple testing/guest mode
- get player name (or information that player is a guest)
- send statistics to Kongregate
- add your own functions easily
Code is not secured in any way - you can modify it (or even must!) if you want.
Instructions how to use Kongregate API:
LWJGL game
- Make new class somewhere in code, name it API and paste this code: http://pastebin.java-gaming.org/5c444707b34 then initialize this class in your init class. It must be public static like “public static API api;”.
- Do you have server? If not, you can use Dropbox Public/<your_game_folder> to store your game files.
- Put game .jar and all libraries to this folder.
- Make new file “KongregateShell.html” in this folder and paste this code: http://pastebin.java-gaming.org/df781027735, fill YourGameWidth and YourGameHeight with proper values (+20 pixels for each value or your game will have scrollbars on both sides).
- Make new file “Frame.html” in this folder and paste this code: http://pastebin.java-gaming.org/c44408b7432. Fill it with appropriate values and modify if needed.
- Everything is ready! Now you can add new game to Kongregate. Copy “KongregateShell.html” public link and paste it in second step of game uploading as IFrame.
- Please make sure that all jars are signed.
Player name is ready to use in about second after game is fully loaded.
You can use Kongregate API by calling public void setRequest(String type, String name, int val). Currently as type you can use only “score” which will send statistics to Kongregate. Please make sure that earlier you initialized new statistic in Kongregate API system.
Tips for new Kongregate developers:
- Try to add as much statistics as possible (these may be invisible in leaderboards - just add them, because this allows your game to get badges if rating is high enough). And remember - most players love stats, so just adding them may make your game much more popular.
- Avoid “Add type” statistics - these are sensitive to bugs and connection errors.
- Report statistics often, possibly even all of them at the same time. Don’t split stats code across all classes, store them in single class and call it.
- If your game have difficulty levels - MAKE STATISTICS SEPARATE FOR EACH SETTING!
- Try to add invisible (or visible) statistics for all things that may get badge from Kongregate, like game finished, earned money, level 10 finished in 40 seconds etc.
Work in progress:
-virtual goods API
-offline/testing mode
-Java version checker and warnings displayer