Multiplayer Games using Google Sheets

Google Sheets For Multiplayer Prototyping

The most essential part of a multiplayer game is the ability for players to communicate with each other in some way. The simplest way to achieve this is for players to have shared access to a database that they both can read from and write to. When building multiplayer prototypes, it can be a hassle to setup a server and database and to then manage connections between players. What if there was a free database that existed somewhere and which players could perform operations on? Well, a database can simply be a table consisting of columns and rows; exactly the same as a spreadsheet. Google Sheets is a popular free online spreadsheet application which can be read from and written to via APIs.



The idea here is to use Google Sheets as our backend database for our multiplayer game prototypes. In order to do this, we need to be able to read and write to the sheets via Javascript. To read from the sheet, we can use a library called Sheetrock which allows us to quickly connect to a Google Sheet and query it using Google's Visualization Query Language. Writing to the sheet is a little bit trickier as it involves writing a script using the Google App Script scripting language. We can write a function to update specific rows in the sheet. This function is then invoked via an HTTP POST request and performs the update.



In order to structure things properly, each row in the sheet must be identified by a unique id. This id can then be used to retrieve and update information in the specific row. When a player sets up a multiplayer game, a new id is randomly generated and a row is added to the sheet with this id. The Google App Script returns the id that was generated and the player is presented with a URL which includes the id. The player can then send this URL to a friend to challenge him to a game. 

When the opponent browses to this URL, we can extract the game id from the query string and use it to read and write to the database. In order to detect changes to the database, the clients must poll the Google Sheet periodically. By interacting with the sheet in this way, the players can effectively play with each other. This type of setup lends itself well to turn-based multiplayer games.


Comments


  1. When you receive the video bingo bash completely free chips used, you could save yourself a good bit. More information on Free bingo bash chips on steemit.com.

    ReplyDelete
  2. I can’t imagine focusing long enough to research much less write this kind of article. You’ve outdone yourself with this material. This is great content 0and also found some interesting topic is Google Play Services the heartbeat of Android smartphone

    ReplyDelete
  3. Such a wonderful message with a good outlook. It was a pleasure to read it. It's simple to comprehend. And, as a gamer, I'd like to recommend a shader pack for Minecraft. You can get the BSL Shaders  set here, and I'm sure you'll enjoy it.

    ReplyDelete

Post a Comment

Popular posts from this blog

Caribbean Games - Part 1: All Fours

Caribbean Games - Part 2: Pitch