Gamerzilla For Godot

Main - For Game Developers - For Godot - For Game Launchers - Source Code


For general game developer questions like "Why should I support it?" see For Game Developers section

Where can I get the gdnative binaries?

Binaries for 64-bit Windows and 64-bit Linux are available on the Main page. The Windows binaries include gamerzilla, curl, jansson and zlib1 libraries. Linux distributions typically install curl and jansson by default so only gamerzilla library is included.

How do I use it?

In your Godot project, create a directory gdnative. Extract the Windows and Linux gdnative binaries into this directory.

Load the project in godot. Right click in the resource dialog and create a new resource. Search for GDNativeLibrary. In the bottom contextual panel at the bottom you will see where you can specify the library to load for each platform. For 64-bit Windows select libgdgamerzilla.dll for the dynamic library and gamerzilla.dll, jansson.dll, libcurl.dll and zlib1.dll as dependencies. For 64-bit Linux select libgdgamerzilla.so for the dynamic library and libgamerzilla.so.0 as the dependency.

After that is setup, create another new resource. Search for NativeScript. Set the library to the GDNativeLibrary you just added. For class name enter Gamerzilla.

Before you can award achievements to players, you need to define the achievements. Typically you specify the achievements in a json file.

{
	"shortname": "test",
	"name": "Test Game",
	"image": "res://gamerzilla/test.png.res",
	"version": "1",
	"trophy": [
		{
			"trophy_name": "Winner", 
			"trophy_desc": "Win the game", 
			"max_progress": "0",
			"trueimage": "res://gamerzilla/true.png.res",
			"falseimage": "res://gamerzilla/false.png.res"
		},
		{
			"trophy_name": "Dragon Slayer",
			"trophy_desc": "Kill five dragons",
			"max_progress": "5", 
			"trueimage": "res://gamerzilla/true.png.res",
			"falseimage": "res://gamerzilla/false.png.res"
		}
	]
}

This example places all gamerzilla files in a subdirectory. You don't need to do this. The file itself would be call test.game.tres. Godot automatically converts png files to a different format for loading. The files have been renamed to add .res as the file extension to prevent this conversion.

In your project you need to load the NativeScript resource. Since not all platforms support Gamerzilla, it is best to check if the script loaded properly before calling it.

var gzilla = preload("res://gdgamerzillascript.gdns").new()
if (gzilla):
	print(gzilla.start(false, OS.get_user_data_dir()))
	gzilla.setGameFromFile("res://gamerzilla/test.game.tres", "")

For giving an achievement you call the SetTrophy method.

if (gzilla):
	gzilla.setTrophy("Winner")

If you want to set progress on an achievement there are functions to get and set the current progress.

if (gzilla):
	var count = gzilla.getTrophyStat("Dragon Slayer")
	gzilla.setTrophyStat("Dragon Slayer", count + 1)

If the player has achieved the maximum progress, the achievement is automatically awarded.