C SDK
Loading...
Searching...
No Matches
Pley C SDK

This is the Pley native SDK reference documentation, the libraries and headers are available for download in the game manager.

What's available in the package:

include/
pley.h # Header file with the definition of all our functions and structs
lib/
pleysdk.bundle # Lib for developing on OSX
libpleysdk.bc # Emscripten lib compiled with emcc 2.0.16
libpleysdk.so # Linux shared object
pleysdk.dll # Windows dll

Example

#include <pley.h>
Pley* pley_sdk;
PleyDestroy pley_destroy;
const char* cloud_storage_path;
const char* username = "anon";
void sync_cloud_storage_cb(PleyResult res, void *data) {}
void init_cb(PleyResult res, Pley* sdk, PleyDestroy destroy, void* data) {
/* Try to verify the result of Pley's methods */
if (res != PLEY_RESULT_OK) {
fprintf(stderr, "Error while initializing Pley SDK: %d\n", res);
exit(EXIT_FAILURE);
}
pley_sdk = sdk;
/* This function should be call when you exit the game to terminate the sdk before */
pley_destroy = destroy;
/* Retrieve username of the player */
pley_sdk->auth_kit->get_username(&username);
/* Retrieve the folder path where you can save your files */
pley_sdk->file_kit->get_cloud_storage_path(&cloud_storage_path);
char* file_path;
asprintf(&file_path, "%s/%s", cloud_storage_path, "my_save");
FILE *save = fopen(file_path, "w+");
fprintf(save,"level:%d", 7);
fclose(save);
/* Sync your files in the cloud storage folder */
pley_sdk->file_kit->sync_cloud_storage(sync_cloud_storage_cb, NULL);
}
int main() {
/* Address of the running CLI for development, not needed for emscripten build */
char dev_host[] = "127.0.0.1:23000";
PleyInitParams params = {nullptr};
strncpy((char*)params.dev_host, dev_host, sizeof(dev_host));
/* Init the sdk, this is a blocking call in non EMSCRIPTEN builds */
pley_init(&params, init_cb, NULL);
while (true) {
/* Your game */
/* [...] */
}
/* Terminate the pley SDK */
pley_destroy(pley);
return 0;
}
PleyResult(* get_username)(const char **username)
Definition pley.h:294
PleyResult(* get_cloud_storage_path)(const char **ptr)
Definition pley.h:171
void(* sync_cloud_storage)(PleyBasicCB callback, void *callback_data)
Definition pley.h:172
PleyAuthKit * auth_kit
Definition pley.h:476
PleyFileKit * file_kit
Definition pley.h:479
PLEY_SDK_API PleyResult pley_init(PleyInitParams *params, PleyInitCB callback, void *callback_data)
Initialize the Pley SDK, the call is blocking on non EMSCRIPTEN build.
void(* PleyDestroy)(Pley *pley)
Definition pley.h:488
Definition pley.h:474
Definition pley.h:466
int32_t PleyResult
Definition pley.h:41
@ PLEY_RESULT_OK
Definition pley.h:44