Distributed Snake Game is a single-player adaptation of the classic Snake game, built on OpenHarmony to demonstrate distributed control and display across seperate devices. It separates control input and game rendering, offering a clear showcase of cross-device collaboration.
Note:
This example uses system interfaces, so you need to manually replace the Full SDK to compile successfully. For specific steps, refer to the Replacement Guide.
- Two OpenHarmony-compatible devices (e.g.,
Dayu200 Development BoardandOpenHarmony Developer Phone) - Valid network connection
- Proper permissions (
ACCESS_SERVICE_DMandDISTRIBUTED_DATASYNC)
- Discover nearby devices on the same networkAdd commentMore actions
- Authenticate and pair discovered devices using a PIN code
- Send
commandfrom controller to receiver in real time
1. Clone the repository
git clone https://github.com/imansmallapple/app-Snake.git2. Build and Deploy
- Ensure you are using API level 11Add commentMore actions
- Confirm your app is a
system-levelapplication - Sign the application with valid signature configurations
- Connect two OpenHarmony-compatible devices (e.g., Dayu200 Development Board and OpenHarmony Developer Phone)
- Ensure both devices are connected to the same network
- Click the
Runbutton in DevEco Studio to install the application
Note:
See this tutorial for how to configure the project as a
system-levelapplication.
1. Install the app on both devices Make sure both devices support OpenHarmony and are connected to the same network.
2. Pair device
- Tap the Find Nearby Device button
- Select the receiver device from the pop-up list
- A verification box will appear on the receiver device; after it is accepted, a random PIN code will be generated
- Enter the PIN code on the sender device
- Pairing is complete
3. Determine roles
Once paired, the initiating device is labeled as the Sender, and the other as the Receiver.
4. Game start
- Click Start button the start the game, user can control the snake direction by tapping the direction button on the controller.
- User can also control the game status with with different buttons:
Stop,Continue,RestartandEnd.
5. Game Rules
- The game is end once snake hit on the wall, user can grant 10 scores by eating a food.
6. Unbind if needed
- Tap Unbind to disconnect the paired device and reset the session.
The project is implemented based on provided template, check more information from this repo.
