javascript - How to program quick interaction in multiplayer browser games? -


i have been programming lot of multiplayer browser games in past needed interaction between player, since more strategies , "building" games, interaction not main problem.

i able of stuff jquery, ajax , php this:

  1. someone makes change overall content of game - ajax fires php script stores change in database.

  2. your client side code continuously runs ajax script, each time firing php script searches database changes , if there any, notified or content (html code) of page updated based on changes.

here example of talking about:

setinterval(function() {         $.ajax({         url: "checkupdates.php",         type: "post",         datatype: "json",         success: function(data) {             // changes based on returned data         }     }); }, 1000); 

but developing games interaction main factor. let tennis need track position of ball both players movements. simple approach store values in database , update page content mentioned function. not possible because if fire ajax function in quick successions slow down browser. issue there "big" delay between firing ajax function , making changes based on result.

therefore questions are:

  1. is there better way solve problem ajax? approach overcome mentioned problem (firing ajax function every e.g. 0.1 second).

  2. is possible make work in php , relation databases or need use node.js/python backend nosql databases? (which faster guess)

  3. what current state of art in field?

even though might quite broad question, have not find strictly mention approach not suitable.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -