When it comes to game development, an often forgotten component comes in the form of a database for storing gameplay information. The database can contribute to numerous roles, such as storing user profile information, game state, and so much more.

In fact, I created a previous tutorial titled Creating a Multiplayer Drawing Game with Phaser and MongoDB. In this drawing example, every brushstroke made was stored in MongoDB.

In this tutorial, we’re going to look at a different data component for a game. We’re going to explore leaderboards and some of the neat things you can do with them. Like my other tutorial, we’ll be using Phaser and JavaScript.

To get an idea of what we want to accomplish, take a look at the following animated image:

Phaser with MongoDB Leaderboard Example

The above game has three different screens, which are referred to as scenes in Phaser. The first screen (first few seconds of gif) accepts user input for a username and also gathers geolocation information about the player. The second screen is where you actually play the game and attempt to accumulate points (by collecting leaves) while avoiding bombs! Finally, the third screen is where your score and location information is submitted. You’ll also see the all-time top scores as well as the top scores near your location, all of which can be queried easily using MongoDB!

#javascript #mongodb #game-development #developer

How to Create a Game with a Functioning Leaderboard using Phaser, JavaScript and MongoDB
24.30 GEEK