Sui Gaming SDK (Move) Overview and Tutorial
September 29th, 2022

Sui and gaming

As one of the initial industries to rapidly adopt web3, gaming is a frequent topic of discussion. Existing web3 games may be viewed as investments, as player retention is influenced by the market situation instead of the games themselves.

What therefore is lacking in present web3 games? First, an excellent web3 game must provide a unique experience compared to web1 and web2 games. To truly and honestly shine, web3 games must utilise the benefits of entirely on-chain, dynamic, and configurable digital assets with verified ownership in a meaningful way. These qualities may enable inventive gaming and ecosystems, generating tremendous value and engagement.

Second, great games necessitate the expertise of seasoned game designers and builders who know how to construct games and design enjoyable, user-centric experiences. There is a plethora of talent willing to develop in web3. Still, its originality has been hampered by platform limits and the arduous learning of a new programming language.

With Sui, I think game developers should be allowed to build whatever experience they can conceive, unrestricted by platform performance or fees. Creating amazing games should not necessitate smart contract expertise from game developers. Instead, they should concentrate on what they do best: creating cool games for players.

Smart contracts on Move

Move is impressive: it is safe, expressive, and resistant to re-entrancy; nonetheless, Move mastery is not necessary to create a memorable experience on Sui. They will release gaming SDKs that handle popular use cases and game asset-related capabilities to make it easier for developers and producers to begin utilising Sui for gaming.

How they did it

Sui Gaming SDK were developed by the game development studio GenITeam using both the Unity SDK and the Sui APIs. GenITeam’s developers who worked on this collaboration are neither smart contract nor Move developers. They constructed a data model based on their input and supplied basic APIs. With these APIs, GenITeam could mint fully on-chain NFTs that are mutable, own other on-chain assets, and freely transfer to other applications.

GenITeam’s developers who worked on this collaboration are neither smart contract nor Move developers. They constructed a data model based on their input and supplied basic APIs. With these APIs, GenITeam could mint fully on-chain NFTs that are mutable, own other on-chain assets, and freely transfer to other applications. The first version of the Sui Monstars game is currently playable, and smart contracts to produce and update monsters are in place. Here are examples of APIs.

API Move call - Create Monster

POST /call with body:

    {
       "sender": "{{owner}}",
       "packageObjectId": "0x2",
       "module": "geniteam",
       "function": "create_monster",
       "args": [
           "0x{{player_id}}",
           "0x{{farm_id}}",
           "0x{{pet_monsters}}",
           {{monster_name}},
           {{monster_img_index}},
           {{breed}},
           {{monster_affinity}},
           {{monster_description}}
       ],
       "gasObjectId": "{{gas_object_id}}",
       "gasBudget": 2000

API Move call - Update Monster

POST /call with body:

    {
       "sender": "{{owner}}",
       "packageObjectId": "0x2",
       "module": "geniteam",
       "function": "update_monster_stats",
       "args": [
           "0x{{player_id}}",
           "0x{{farm_id}}",
           "0x{{pet_monsters}}",
           "0x{{monster_id}}",
           {{monster_level}},
           {{hunger_level}},
           {{affection_level}},
           {{buddy_level}}
       ],
       "gasObjectId": "{{gas_object_id}}",
       "gasBudget": 2000

API Move call - Read Monster Data

GET /object_info?objectId={{monster_id}}

Smart contract: Create Monster

   struct Monster has key, store {
        info: Info,
        monster_name: String,
        monster_img_index: u64,
        breed: u8,
        monster_affinity: u8,
        monster_description: String,
        monster_level: u64,
        monster_xp: u64,
        hunger_level: u64,
        affection_level: u64,
        buddy_level: u8,

        // ID of the applied cosmetic at this slot
        applied_monster_cosmetic_0_id: Option<ID>,
        // ID of the applied cosmetic at this slot
        applied_monster_cosmetic_1_id: Option<ID>,
    }

    // Create a Monster and add it to the Farm's collection of Monsters
    public entry fun create_monster(_player: &mut Player,
                              farm: &mut Farm,
                              pet_monsters_c: &mut collection::Collection,
                              monster_name: vector<u8>,
                              monster_img_index: u64,
                              breed: u8,
                              monster_affinity: u8,
                              monster_description: vector<u8>,
                              ctx: &mut TxContext
    ) {

        let monster = create_monster_(
            monster_name,
            monster_img_index,
            breed,
            monster_affinity,
            monster_description,
            ctx
        );

        // Check if this is the right collection
        assert!(*&farm.pet_monsters_id == *ID::id(pet_monsters_c), EMONSTER_COLLECTION_NOT_OWNED_BY_FARM);


        // Add it to the collection
        collection::add(pet_monsters_c, monster);
    }

    // Creates a basic Monster object
    public fun create_monster_(
        monster_name: vector<u8>,
        monster_img_index: u64,
        breed: u8,
        monster_affinity: u8,
        monster_description: vector<u8>,
        ctx: &mut TxContext
    ): Monster {

        Monster {
            info: object::new(ctx),
            monster_name: ASCII::string(monster_name),
            monster_img_index,
            breed,
            monster_affinity,
            monster_description: ASCII::string(monster_description),
            monster_level: 0,
            monster_xp: 0,
            hunger_level: 0,
            affection_level: 0,
            buddy_level: 0,
            applied_monster_cosmetic_0_id: Option::none(),
            applied_monster_cosmetic_1_id: Option::none(),
        }
    }

Smart contract: Update Monster

    // Update the attributes of a monster
    public entry fun update_monster_stats(
        _player: &mut Player,
        _farm: &mut Farm,
        _pet_monsters: &mut collection::Collection,
        self: &mut Monster,
        monster_level: u64,
        hunger_level: u64,
        affection_level: u64,
        buddy_level: u8,
    ) {
        self.monster_level = monster_level;
        self.hunger_level = hunger_level;
        self.affection_level = affection_level;
        self.buddy_level = buddy_level;
    }

Protype 1: Sui Monstar

The first prototype is Sui Monstar, a pet simulation game.

Gameplay:

  • Play with, feed, and outfit your canine and feline companions.

  • Transform your pets using affinity runes.

  • Embellish your farm.

  • Increase your farm and pet levels through gameplay and interactions.

You capture adorable monstars in Sui Monstars and observe them approach you as you feed and engage with them. These monstars, as well as your farm and accessories, are all on-chain NFTs. Traits like health, friendliness, and equipment change in real time as you progress through the game.

Update NFT properties
Update NFT properties

Prototype 2 Sui Battler

You've reached Sui Battler, the area where your cute monstars can become powerful warriors.

Gameplay:

  • Combat enemy waves while gaining experience and power-ups.

  • Obtain assistance from your own pet via Sui Monstars.

  • In Sui Monstars, evolve your pet to acquire new combat powers.

  • Your monstars record the fight history on-chain!

Unlock special abilities
Unlock special abilities

Why are they vital

  • Mutable NFTs result in a more diverse and inventive gaming.

  • No more complex fixes or burning NFTs to "alter" them, thus losing all data and history.

  • APIs that prioritise usability make building on Sui simple. Unparalleled scalability and fast settlement imply that changes in asset status, ownership, and balance can occur simultaneously with gaming. No more sluggishness or workarounds. The limit is creativity. Creators are permitted to freely utilise their assets across several applications and games. The next generation of game economies is enabled by fully on-chain, composable NFTs with a rich history.

I recommend that you check my very simple game named Suicide that I developed using the Sui Gaming SDK with Move.

Further reading

Subscribe to Eray
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.
More from Eray

Skeleton

Skeleton

Skeleton