I am also building a game with JS/PHP and here is my plan: have a plain text file on the server.
This should result in much faster server to client communication.I haven't done this myself, but I think the basic principle is that you can delay for 5 to 10 seconds per ajax call, performing a new call whenever one times out or is returned from the server with data.Also, I would recommend a javascript framework ( for example) to make the ajax calls more manageable. If you're determined to use PHP/JS/Ajax, then I would suggest you read about using the PHP function to delay returning the results of an ajax call until the server has something to say. Then, as a backend, you could use MySQL or XML or whatever you want (but I would consider MySQL as a better solution, because XML is just a text file which needs to be opened, read, written and closed and the database is designed to be faster than that). And there are many implementations for Comet in JS/PHP, just Google that. Works perfectly for p2p things like instant messenger, for example, because it pushes data to browser without browser needing to constantly poll the server. I just don't know what I should use for the client to client communication - I initially planned on using constant 1/2 second AJAX calls to the PHP script using mySQL to store the game/user data, but I'm afraid that will be too slow and unpredictable.I considered using something like a XML instead of mySQL and using something like the php fopen function - what do you guys think about that?I read in this question, where the poster is considering using XMPP, could that be a good solution?Should I go for a socket? Is that necessary for a game that doesn't require all that much data to be exchanged? What would be required to get this going?Any suggestions on syncing the round time? Or is this something that I even really need to concern myself with?I'm open to all suggestions and really appreciate any help I can get.
Time sync is importantPlayers select and action and at the end of the round, the action is performed, there is a brief intermission to detail actions and a new round begins.I've determined to build this game entirely in JS and PHP (of course AJAX). I'm planning a relatively simple, online, multiplayer game and I'm stumped on what to use for player to player communication.Game details. In SQL, one method could be:If a player can be in more than one game at a time, you'll need to use a Games table which houses all of the current users mapped to a gameplayed identifierIf a player can only be in a single game at a time, make a field for the Player table that states what gameplayed ID each is currently attending.Search for gameplayed ID's to help pair players together and reference the data to each other.As for game state and messages, you can use tables and simply reference the gameplayed ID to help sort this out.
I don't know how to make the players who sign-in to the website to see other players who are also connected to the site and be able to chat with one another.I want to design the game in such a way that 2 players can play with each other and be able to send messages during the game while others groups are playing at the same time.I have designed the map game successfully, but the problem is making the player 1 who log-in to site to see the player 2 who will also log-in and both can get connected to play each other.I will appreciate your responses. I am designing a map game, using PHP and MYSQL.