php multiplayer game - server&client model

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I'm working on a simple round&web-based multiplayer game. The idea of the game is very simple: The players get an array of audio files which they listen to and write the transcripts for in 5 minutes. the player who sends in the most right transcripts gets the most points. its fairly simple and i was able to implement it locally. at the moment i have the .php file which lets me do all this but only in single player. what i'm trying to say is that whenever a player logs him/herself in, the page is loaded anew. what i want to do is to start the game from the server everytime 3-5 players log themselves in, so that the players can play at the same time and their results can be compared at the end of the round.

the thing is, i don't know how to start with this session or server/client model for a multiplayer game. i have read that php isn't ideal for web based multiplayer games because real time data exchange could be problematic, but since that is not really the case here i don't think that should be a major problem. i googled my problem but i have failed to find a solution. any help or advice would be much appreciated. cheers.

edit: is a node.js server what i'm looking for here?

profilepic.png
manpreet 2 years ago

Socket.io/node.js is precisely what you want. If you want to start a tad simpler, you could use ajax and an timeout to poll the server every 30 seconds or whatever time period to get a response concerning other players around. So really either take the active approach with socket "The server has just told me someone joined, someone answered, etc" or the passive ajax approach "Let me ask the server if anything has happened."


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.