0

I wrote a game (will be played on a server) and I want to store the high scores from the players. The stored scores should be available and accessible all the time for all the players.

What would a good approach towards this (I would prefer vanilla.js) is possible?

Dijkgraaf
  • 11,049
  • 17
  • 42
  • 54
Faizy
  • 299
  • 2
  • 12
  • 1
    You tagged it under [javascript] which makes this question, too brad, primarily opinion-based and unclear! – Alon Eitan May 11 '17 at 19:29
  • Possible duplicate of [How to save progress in an html game](http://stackoverflow.com/questions/34847231/how-to-save-progress-in-an-html-game) – anonymous May 11 '17 at 19:33
  • @KeeganKuhn I would say it is a bit different because he is asking how to store the results for all players of the game to see, so I'm assuming its a multi-client game. – Peter LaBanca May 11 '17 at 19:34

2 Answers2

2

Well you will need a server or a service to do this. Since creating your own server requires an actual machine and a lot of work and maintenance, a service might better suit your needs.

The best service I have found, that is free with limited bandwidth, is Firebase. It is a database as a service, and you can use it to store things just like you would locally in a local or session storage. If your game becomes huge and uses a lot of bandwidth, you'll need to start paying, but maintaining a server is not free either.

Peter LaBanca
  • 475
  • 3
  • 9
1

If the scores only need to be accessed during the current session, use variables. For example:

score = 0;
if ( pointEarned ) {
    score++;
}
alert(score);

If you need to access the variable after the session, Toastrackenigma has a great explanation at Stack Overflow.

Community
  • 1
  • 1
anonymous
  • 271
  • 3
  • 16