🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Multiplayer remote and/or local design..

Started by
3 comments, last by Stoffel 23 years, 10 months ago
Let''s say I want to make a board game, something akin to Monopoly. Turn-based, so no real-time problems here. You should be able to create a game that has 8 players: 1 at the host machine 1 also playing at the host machine (take turns) 2 playing on the same remote machine 1 more playing on a different remote machine 2 computer players How would you design this? I tried doing this for the game I''m currently making, tried to use classes so that the game loop just saw a "player" and got turn info back, but it didn''t work out. Anybody have any experience in this? Is it best to create a server and have every player (including local player) be a client?
Advertisement
Are u using directplay here? If it is, it is quite easy.

Every machine needs a list of players in the game. Only one of them will be the server, which will take care of all the turn token and comp players.

The server can have a player since it''s doesn''t have to know it is the server. The server tells the player it has the turn (via a message) and the player can send a message back to the server when it has finish it''s turn. Upon receiving the "I am done" message, the server just move to the next player in the list and sends another message there.

So the while loop only sits and receives message and acts on the "global variable" that is has the turn (which is set by receving a "You got turn" message from the server.)

The tricky part is when you want to use threads for receving messages.
There should not be any problem in doing it. I don''t not about Winsock, only DirectPlay, and it is not difficult, but just be careful.
There should not be a problem with threads too, if you do it right. Create a different receiving message thread for every player in the machine. I don''t know if DirectPlay sends the messages to the corresponding receiving queue or not. If it doesn''t you should check the messages with DPRECEIVE_PEEK in the DP->Receive for every player, and only removing the message from the queue if the message is sent to that player.
You can find problems creating a server and a client player in the same DP object. If so, create one DP object for the server, and another one for the rest of client player (on the same machine)

Eduardo García Sacristán
egarcia@ubisoft.es
Eduardo García SacristánProgrammer. UbiSoft Spainegarcia@ubisoft.es
Oddly enough, I''m much more comfortable with threads & such than I am with DirectPlay (never used it before). I''ll have to take a look at it and see if I can learn the API. Thanks for the tips.
Take a look in the DirectX section at gamedev. I have a article on the basics of DP.

As for threading. Tis more troublesome with window messageboxes rather than DP itself because you need to pause the receiving thread when a messsagebox pops up or the thread would keep receiving data while the program "stops" there.

This topic is closed to new replies.

Advertisement