2019 is the Year of Cloud gaming with the multiple announcements from Google Stadia, Microsoft XCloud, Playstation Now... and recently Google Stadia released this 19th November. Looking back, I was so excited when I first read the news from Google Stadia. Cloud gaming is a very innovative idea and it will definitely become the next generation of not only Game but also other fields of computer science. My curiosity about this technology motivated me to make a POC of Cloud-Gaming for Retro Game.
giongto35 / cloud-game
Web-based Cloud Gaming service for Retro Game
Video Demo
About Cloud Gaming technology
As we know about web-server, the more information backend can provide, the more flexible the frontend can render. Cloud Gaming maximizes backend control and minimizes frontend logic by running Game on server and streaming images/audio to users. In this way, clients are totally decoupled from heavy logic and no longer limited by hardware constraints. If we apply the same methodology to other heavy offline applications like an operating system, E.g run Microsoft Window on Google Chrome Browser like this
Behind Cloud gaming is an art of extremely low latency streaming to ensure user interaction is as smooth as possible. At first, I have a doubt on Google claim because I don't believe the streaming technology reached this advance yet. For that reason, I made this project to verify that claim and the result is above my expectation. In this project, I applied WebRTC with Video/Audio Compression (VP8/OPUS) to optimize package size and implemented a distributed infrastructure to enable horizontal scaling and optimal server pairing for better network latency.
I picked Golang for my POC because Iβm familiar with it the most, then it turned out to work perfectly in my case. Go concurrency design greatly helped when dealing with concurrency and event stream. For example, I can achieve CrowdPlay with just a few lines of code using Golang Fan-in Fan-out pattern.
Feature
Cloud gaming: Game logic and storage is hosted on cloud service. Images and audio are streamed to users in the most optimal way.
Cross-platform: The game is run on web browser, the most universal built-in app. No console, plugin, external app or devices are needed. Chrome with the latest version is recommended for the game.
Emulator agnostic: The game can be played directly without any extra effort to set up the gaming emulator or platform. It is based on Libretro library and ludo
Crowdplay: Follow the idea of crowdplay (TwitchPlaysPokemon), multiple players can play the same game together by addressing the same deeplink. This is the feature Google Stadia promised couldn't deliver for the first release.
Vertically scaled: The infrastructure is designed to be able to scale under high traffic by adding more instances.
Cloud storage: the Game state is storing on online storage, so you can come back and continue playing your incomplete game.
Demo
Single play: http://cloudretro.io
Crowd play: Pokemon Emerald
Arrow key + H (Help) + Z X C V + S (Save) + A (Load) + F (Full screen)
Chrome and Chrome on Android is recommended. It's not working on IPhone and some other explorers. In an ideal network condition, the Game should be run smoothly as in the Video. Because I only hosted the platform on limited servers in US East, US West, Eu, Singapore, you may experience some latency issues + connection problem. You can try hosting the service following the instruction on Github.
Crowdplay
By clicking these deep-link, you can join the game directly and play it together with other people joining the same link.
And you can host the new game by yourself by accessing cloudretro.io and click "share" button to generate a deeplink to your current game.
Disclaimer: You may experience lagging when joining a room, it is because the room is in a different zone. In that case, you can create a new room.
(Two players are playing the Pokemon Emerald together)
How I implemented it in Golang
I had presentation in GopherCon Vietnam 2019 about this topic, you can find the Video and Slide here. You can see my speaker note in the slide as well.
(GoCode Diagram from slide)
Please check Github repo and Wiki for more details.
Next in the series
Part 1: How I design a cloud gaming service
How I built a cloud Gaming service, part 1
giongto35 γ» Dec 4 '19
Author
Nguyen Huu Thanh
Tri Dang Minh
If you like the project, please give me a star or contribute to Github
giongto35 / cloud-game
Web-based Cloud Gaming service for Retro Game
CloudRetro
Open-source Cloud Gaming Service For Retro Games
Video demo: https://www.youtube.com/watch?v=GUBrJGAxZZg
Technical wrapup: https://webrtchacks.com/open-source-cloud-gaming-with-webrtc/
CloudMorph: https://github.com/giongto35/cloud-morph: My current focus
on generic solution for cloudgaming
Discord: Join Us
Try it at cloudretro.io
Direct play an existing game: Pokemon Emerald
Introduction
CloudRetro provides an open-source cloud gaming platform for retro games. It started as an experiment for testing cloud gaming performance with WebRTC and Libretro, and now it aims to deliver the most modern and convenient gaming experience through the technology.
Theoretically, in cloud gaming, games are run on remote servers and media are streamed to the player optimally to ensure
the most comfortable user interaction. It opens the ability to play any retro games on web-browser directly, which are
fully compatible with multi-platform like Desktop, Android, IOS.
In ideal network condition and less resource contention on servers, the game will run smoothly as in theβ¦
Top comments (3)
This is amazing! I had something similar in mind for the gba but i know nothing about emulating games:)
Thank you :D May I know your project also.
Lol, it was a typo, i meant "in mind"