Skip to content

solana-developers/cube_shift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cube_shift

Cube Shift shows a simple implementation of the Solana Game Shift Api.

The game is similar to vampire survivors or blob heroes and is written in Unity game engine.

image

Here is a live version of the game: https://solplay.de/cubeshift/

The game has a next.js api that communicates with the Solana Labs Game Shift api. From Unity it calls a next js app deployed in vercel which forwards the requests to the shift api using an API key.

Signup to get your own api key here: https://gameshift.solanalabs.com/ https://app.gameshift.dev/

Features of game shift used:

  • Sign up player using a client token and email address
  • Minting assets in form of new characters for the game. Fire mage which has extra fire bolts and Monkey which starts with extra banana skill.
image

Players login with email adress and the access token is saved in the client for now.

Feel free to fork the game and use it or open PRs right here.

Integrating GameShift with Unity

This document provides guidelines on integrating GameShift, into your Unity game to handle transactions and game state securely and efficiently.

Recommended Game Architecture

When integrating GameShift into your Unity game, we recommend the following architecture:

Gameshift client and server architecture

  • Game Client: A Unity application that the player interacts with. It is responsible for presenting the game state and handling user inputs.
  • Server: Your custom backend server acts as an intermediary between the Game Client and GameShift API. It is crucial for several reasons:
    • Security: The server ensures that sensitive GameShift API calls are not exposed to the client, reducing the risk of unauthorized access and manipulation.
    • User Profiling: Stores persistent user data that lives with the game, such as profiles, progress, and statistics.
    • Custom Game Logic: Allows the implementation of custom game logic that is not handled by the Game Client or GameShift API. Utilizing a server will make this data processing faster than in Unity.
  • GameShift: Gameshift will contain the canonical on-chain data for your game

The server plays a major role in this architecture by processing game logic, securely interacting with the GameShift API, and updating the game state based on the responses.

Workflow

The interaction between the Game Client, Server, and GameShift API typically follows these steps. We've included sample code to demonstrate a potential integration—the github repo is available here, we will follow sample code to show how a player might be awarded an nft after clearing a level

  1. Action Sending: The Game Client sends player actions to the Server. code

  2. Data Processing: The Server processes these actions and sends relevant requests to the GameShift API, and receives an appropriate response. code

  3. State Update: The Server updates the game state and sends it back to the Game Client. code