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:
someone makes change overall content of game - ajax fires php script stores change in database.
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:
is there better way solve problem ajax? approach overcome mentioned problem (firing ajax function every e.g. 0.1 second).
is possible make work in php , relation databases or need use node.js/python backend nosql databases? (which faster guess)
what current state of art in field?
even though might quite broad question, have not find strictly mention approach not suitable.
Comments
Post a Comment