🎉 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!

Winsock woes...

Started by
3 comments, last by RageMatrix 23 years, 6 months ago
Hi, After completing a Java chat server, I mistakenly considered myself capable of writing a multiplayer video game under DirectX using Winsock / DirectPlay. Oh, silly, silly me. Obviously, sending text data to a socket every time the user presses enter is not actually gonna cut it when writing a game. So I have some questions... 1. Using winsock, can you send a structure to the socket? The reason is, I am writing a small 2D multiplayer game where the two players can move around the arena (screen) and shoot. Therefore, I have two "messages" that I can send to each player. When a players position has changed, I send the MOVE_MSG structure and when the player shoots, I send a FIRE_MSG structure. Each client then had enough information from these structures to draw the relevent information to the screen. (I think). 2. Should I use Winsock instead of DirectPly or vice-versa? Which is better for a small (max four players) Internet game? 3. How can I make sure that each player is displaying the same game information? 4. Should I abandon this project for a while and work on something simpler, like, perhaps, network Pong, where all I have to worry about is the Y position of each player? Thanks! Jon. -- -=Kicking Butt and Writing Code=-
Advertisement
1. send() and friends sends a buffer, not a string. Don''t let the char * fool you. To send a structure use something like "send(socket, (char *) &foo, sizeof(foo), 0);".

2. This is a religous issue. I prefer the control and simplicity of winsock. Others prefer the high-level features of DirectPlay.

3. Depending on exactly what you need this problem ranges from trivial to extremely difficult.

4. Simpler is better when you''re first learning.

-Mike
I would have to add Physically Impossible to #3 list.

I'd start by making a server program, a client program, and have the server simply repeat whatever one client sends to every other client. x,y position updates is a place to start...

Edited by - Magmai Kai Holmlor on December 18, 2000 7:55:08 PM
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
I dont think #3 is impossible, say for instance a checkers game. Im sure you can be ceratin that both players see the board the same before either moves. However for a FPS game, there are allowances for error, given the bandwidth and latecny constraints.

Good Luck

-ddn
The game itself is a top-down 2d multiplayer game, using structs to hold the data for each game element and globals for system stuff like graphics/sound, etc. Basically, its a deathmatch game with 1-4 players and AI bots. At the moment, the play area is only one screen big, but I hope to make it a tile based game with rooms and mazes. The AI of the bots in single-player mode will "remember" the contents of each room by a series of arrays and bit-codes, thus allowing for more realistic play. Both players act in real time, so its important to get the network design right first time (which is why I''m stressing over it).

This is my first Windows videogame, and I guess I''m including stuff I don''t know how to do yet, but this game has been in my head for a year and I''ve got to write the damn thing just to get it out

Expect more questions in the future

-=Kicking Butt and Writing Code=-

This topic is closed to new replies.

Advertisement