Sign in to follow this  
Felipe Budinich

GameZyme Beta; Saves, Leaderboards, Domain Whitelist, User Authentication, Define Game Variables from the Server

Recommended Posts

Hello Everyone :D!
We are launching GameZyme's closed beta; we provide a wide array of services from an unified crossplatform api and backend; user authentication (social login, or email + password), player saves, global and social leaderboards, a domain whitelist to protect yourself from pirate portals, the ability to define game variables and retrieve them from  the server (for example, this would allow you to change the amount of "player lives" across platforms, without pushing new binaries to the appstore/google play).
The platform will have no cost for beta users until November 2016 (after that, we will move to a pricing structure similar to Digital Ocean's), the idea is to polish our current features, and develop features that you need. 
If you are interested, request beta access here: http://www.gamezyme.com/#request

Also, you can download our Javascript SDK from Github: https://github.com/GameZyme/js-sdk


GameZyme Javascript SDK

Initialize

To use GameZyme, you must have an account (sign in here), and a game set up on the dashboard. Then you just need to add the SDK and your game's public key to your HTML.

You can get your game's public key in the Settings - Basic section of our dashboard.

Settings - Basic

Example

<head>
    <!-- Host it locally -->  
    <script src="/js/gz.min.js"></script>
    <!-- Or Get it from an external source -->
    <!-- <script src="https://rawgit.com/GameZyme/js_plugin/master/dist/gz.min.js"></script> -->
    <script>
        var publicKey = "<YOUR GAME'S PUBLIC KEY>";

        Gamezyme.init(publicKey, function(result) {
            // Connection suceeded
            console.log("Connected and ready!");
        }, function(error) {
            // Something went wrong
            console.log("Something went wrong! \n" + "Error detail: " + error);
        });
    </script>
</head>

Game

Using the GameZyme's dashboard you can set variables that can be retrieved from your game in the Properties - Gamevars section.

Properties - Gamevars

.getAllVars(callback)

Retrieve all game variables set in GameZyme's dashboard.

Example

var gameVars = {};

Gamezyme.game.getAllVars(function(response) {
    gameVars = response.result;
});

.getVar(key, callback)

Retrieve a single variable set in GameZyme's dashboard.

Example

var key = "boss01_health";
var value;

Gamezyme.game.getVar(key, function(response){
    if (typeof response.error == 'undefined') {
        value = response.result;
    }
});

Server

.ping(callback)

Get server Status

Example

Gamezyme.server.ping(function(response) {
    if (typeof response.error == 'undefined') {
        // everything's fine
    }
});

Player

These methods are related to the player's information. Here you can login, logout, save player data, among others.

.forgotPassword(email, callback)

Send an email to the player with the steps to recover his/her password.

Example

var email = "email@example.com";

Gamezyme.player.forgotPassword(email, function(response) {
    if(response.result === "success") {
        //Email sent
        console.log("Check your email to recover your password");
    }
});

.getData(callback)

Gets the player's peristed game data

Example

var playerData = {};

Gamezyme.player.getData(function(result){
   if(result.status === 'success') {
       // Successfully retrieved data
       console.log('Data retrieved');
       playerData = result.response;
   }
});

isLoggedIn(callback)

Check if the player is already logged in

Example

Gamezyme.player.isLoggedIn(function(result) {
   if(result.response === true) {
       // This means the player ir already logged in
       console.log('Player already logged in');
   }
});

localLogin(email, password, callback)

If a player has an account, use this function to login into your game. Parameters email and password must be Strings.

Example

var email = 'foo@bar.io';
var password = 'foobar';

Gamezyme.player.localLogin(email, password, function(result) {
    var error = result.error;
    if (error) {
        // Maybe there's an error with his email or password
        console.log(error.message);
    } else {
        // Player logged in successfully
        console.log(result.response);
    }
});

.localSignUp(email, password, name, callback)

Use this function to register a player with an email, a password and his/her name. All these parameters must be String

Example

var email = 'foo@bar.io';
var password = 'foobar';
var name = 'Scott C. Alves';

Gamezyme.player.localSignUp(email, password, name, function(result) {
    var error = result.error;
    if (error) {
        // Probably the player exists
        console.log(error.message);
    } else {
        // Player signed up successfully
        console.log(result.response);
    }
});

.logout(callback)

Use this method to logout the player.

Example

Gamezyme.player.logout(function(result){
   if(result.status === 'success') {
       // Player logged out
       console.log('Player logged out');
   }
});

.me(callback)

Retrieve information about the player.

Example

var player = {};

Gamezyme.player.me(function(result){
   if(result.status === 'success') {
       // Successfully player info retrieved
       console.log('Player info retrieved');
       player = result.response

       // Player's email
       console.log(player.email);
       // Player's identifier
       console.log(player.identifier);
       // Player's name
       console.log(player.name);
       // Player's typeIdentifier (local sign-up or facebook)
       console.log(player.typeIdentifier);
       // Player's profile picture (Only available if the player's typeIdentifier is "facebook")
       console.log(player.urlProfilePicture);
   }
});

.openPopupLoginFacebook(callback)

Open popup for Facebook login

Example

var btnLoginFacebook = document.getElementsById("fb-login");

btnLoginFacebook.onclick = function(e) {
    Gamezyme.player.openPopupLoginFacebook(function(result) {
        var error = result.error;
        if (error) {
            console.log(error.message);
        } else {
            console.log(result.response);
        }
    });
}

.saveData(callback)

Persist the player's game data

Example

var data = {
    currentLevel: 5,
    money: 3200,
    score: 5000,
};

Gamezyme.player.saveData(data, function(result){
   if(result.status === 'success' && result.response === true) {
       // Data saved successfully
       console.log('Data saved');
   }
});

Leaderboard

In GameZyme we handle 2 type of crossplatform leaderboards: Global leaderboard and Friends leaderboard. Using these methods you can show both leaderboards.

.getFriends(options, callback)

Get the player's friends leaderboard (currently we only support Facebook friends)

Example

var options = {
    order: 'DESC' // This accepts only 2 strings: 'DESC' and 'ASC'
};

Gamezyme.leaderboard.getFriends(options, function(result){
   if(result.status === 'success') {
       // List retrieved successfully
       console.log(result.response);
   }
});

.getGlobal(options, callback)

Gets all players leaderboard

Example

var options = {
    limit: 10,
    order: 'DESC' // This accepts only 2 strings: 'DESC' and 'ASC'
};

Gamezyme.leaderboard.getGlobal(options, function(result){
   if(result.status === 'success') {
       // List retrieved successfully
       console.log(result.response);
   }
});

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.