SteemGG SDK - A Steem Blockchain Toolkit for Game Developers
Introducing the SteemGG SDK
Following a few months of hardwork, our developers have finally completed the first stages of the SteemGG SDK, a toolkit for HTML5 game developers to allow them to have their games interacting with the Steem Blockchain through the SteemGG server. In particular, with the first stage, we have implemented the functionality of load and save games, score leaderboard, and getting user information.
Wiki Page: https://github.com/steemgg/steemgg-website/wiki/SteemGG-SDK
Online Testing Tool: https://steemgg.github.io/steemgg-website/sdk-toolkit.html
Demon: https://steemgg.com/#/game/play/53
What is SteemGG SDK
SteemGG SDK is a javascript library which game developers can leverage to interact with the SteemGG website and the Steem Blockchain, like save/retrieve the game record to the Blockchain via the SteemGG server, get leader board data, get current user information, etc.
How to get the SDK
The easiest way would be put the following tag into the index.html of your game
<script src="https://unpkg.com/steemgg-sdk/dist/steemgg.sdk.js"></script>
Or you can call
npm install steemgg-sdk
to get the steemGG sdk module installed and import the steemgg.sdk.js in your game file
How to use the SDK
After you include the sdk javascript to your game, a global variable steemGG
is available. there are several APIs you can call:
steemGG.setKey()
steemGG.setGameRecord(record)
steemGG.getGameRecord()
steemGG.getLeaderBoard()
steemGG.getCurrentUser()
and a special one
steemGG.setDebugMode(true|false)
To start to use the SDK, the normal steps are as follows:
1)You must first set the API key to the sdk by calling steemGG.setKey(apiKeyOfYourGame)
, the key is used to encrypt and decrypt the record between client and the server to prevent user from sending fake record.
You can find the API key of your game in the game editing form:
2)Load the existing game record for the current user by simply calling
steemGG.getGameRecord
A typical game record looks like this:
{
"id": 3141, <---- current game id
"userId": "user1", <---- current user id
"customField": { <---- a custom field, which developer can store any custom fields they want
"score": 90, <---- Note: 'score' is a special field, the value stored in
this field will be used to generate the leader board
"key1": "xxx",
"key2": "yyy",
...
}
}
then initialise the game based on current user's record, if there is no existing record, it will be a empty JSON.
3)Use the steemGG.setGameRecord(record)
method to store the record back to the server. A typical game record to be stored looks like this:
{
"id": 3141, <---- current game id
"userId": "user1", <---- current user id
"customField": { <---- a custom field, which developer can store any custom fields they want
"score": 90, <---- Note: 'score' is a special field, the value stored in
this field will be used to generate the leader board
"key1": "xxx",
"key2": "yyy",
...
}
}
Put any data you need under the customField
property of the record JSON object. Make sure you get the id
and userId
field set as well. Note: You can get the current user by calling steemGG.getCurrentUser
4)If your game needs a leader board, when you save the record, you can set the special property score under the customField
, the value must be a Number and will be used to rank the user record.
Getting the leader board
After setting the score
field, a leader board will be generated for you game automatically. You can get the leader board data for your game by calling
steemGG.getLeaderBoard()
The leader board data will be in format:
[
"user1",
"200",
"user2",
"200",
"user3",
"99"
]
Sample page
To make the testing easier, we have a toolkit page which you can load your game into and check whether your code is getting and setting the correct record. The sample page is here: SteemGG SDK Toolkit. When you are testing your game inside the SDK, make sure you set it to debug mode by calling:
steemGG.setDebugMode(true)
so there will be no encryption, which makes it easier to check the data your game sends. It also means you don't need to call steemGG.setKey
in debug mode.
Coming next
A few new features will be coming soon which will allow the game to:
- adjust the height of the game view
- toggle full-screen mode
- define more leader board fields (currently only support one based on the score field)
- Upvoting inside the game
This post has been included in the latest edition of SoS Daily News - a digest of all you need to know about the State of Steem.
To listen to the audio version of this article click on the play image.
Brought to you by @tts. If you find it useful please consider upvoting this reply.
This looks most useful.
Would you be interested in coming on The GAME Show to talk about the project?
Hey, thanks for the invite and sorry for the late reply. We would love to come on your show at some point, but I have been very busy with personal stuff this year so far, and we are planning to roll out more updates, so may be later in the year when things settles a bit more, we will come on the show! Thanks again!
Really happy to see SteemGG is still alive and kicking! You got some good stuff going, there!
Congratulations @steemgg! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Click here to view your Board
If you no longer want to receive notifications, reply to this comment with the word
STOP
Do not miss the last post from @steemitboard:
Vote for @Steemitboard as a witness and get one more award and increased upvotes!
This is awesome! I'm so happy to hear that work is still being done with SteemGG, and this new SDK is a great addition.
Good luck SteemGG crew, wishing you all the best! Can't wait to give the SDK a try :-) Thank You!
Hey Thanks! Do give it a try and let us know what you think!
This post has been included in the latest edition of SoS Daily News - a digest of all the latest news on the Steem blockchain.
This seems like a great addition to the chain and should provide an assistance to anybody starting off from scratch. Nicely done.
Posted using Partiko Android
Does this use custom_json or a centralized server?
It uses a custom json I think. I will need to check with the tech guys.
Congratulations @steemgg! You received a personal award!
Click here to view your Board
Vote for @Steemitboard as a witness and get one more award and increased upvotes!