Options
All
  • Public
  • Public/Protected
  • All
Menu

Games that run on etherplay are competitive games

players tries to get the best score and winners get rewarded

To ensure fairness, the Etherplay platform verifies each player submission by replaying the game to ensure the validity of the game

For developers this means the game code need to ensure perfect replayability

randomness thus need to be seeded and input need to be recorded

To ease the burden, etherplay.js provide an environment where these issues are automatically solved

To initialise your game you need to call etherplay via etherplay.init

Each game have two components :

  • the shell whose responsability is to show the menu, highscores and game over screen among other (this does not need to be verified as it is not the actual game)

  • the gameloader whose in charge to load and setup the game itself who need to follow strict guidelines to ensure replayability and verification

Both of these object run in separate environment and cannot communicate outside of what etherplay's api provide.

The Shell can only start a game and wait its result

When the game is being executed the shell is being hidden away and vice versa

In the following api documentation method and object tagged with shell are only present in the shell context

Similarly method and object tagged with game are only present in the game context

Item tagged with interface are to be provided / implemented by you

The others are provided by the api though callbacks

Summary

Object literals

etherplay

etherplay: object

etherplay

etherplay.init({
    shell:shell, //the shell setup
    gameLoader:{
        loadGameResources:loadGameResources, //loading game assets or any other required resources to display the game. 
        createNewGame:createNewGame, // game factory executed before every game session
        renderer:renderer //allow you to render the game outside of the game logic
    }
}, {
    input:{
        use:{
            touch:{type:"touch",triggers:["touch","mouse"]}, //setup input named "touch" triggered by touch when available or emulated by mouse
            isJumping:{type:"boolean",triggers:["Keyboard.ArrowUp"]} // setup input named "isJumping" triggered by the keyboard up arrow key
            //more example on the way...
        }
    }
});

init

loadJavascript

  • loadJavascript(urls: string[], callback: function): void
  • allow to load javascript dependencies (in parallel)

    Since you will not have access to html where your game will be embeded this function allow you to load javascript dependencies before hand

    Note that these should be loaded while the game is running

    All game dependencies need to be done loading before the game start to ensure perfect replayability

    Parameters

    • urls: string[]
    • callback: function
        • (): void
        • Returns void

    Returns void