How should I design a multiplayer tetris game?
Should I use peer-to-peer or a client_server method for this game?. I'm want to add network multi-player support to a game I'll be converting from VB to C++. - The game supports up to 4-players on screen at once. (up to 4 boards) - Players can share the same board, i.e. play cooperatively. (2 or more pieces dropping within the same board. The board widths can vary too). I want to allow more than one player on one machine, and be able to connect to other machines with varying number of players. some scenarios: 3 Machines with 1 Player on each 1 Machine with 2 Players <-> 2 Machines with 1 Player each (4 players) 1 Machine with 4 Players (This was done in the old VB version; crowding around the keyboard and using a gamepad :) ) How exactly should I set this up in a networked environment? If p2p, should I pass the input between players or just the positions of the moving pieces? Also, what library should I use if I'm new to network stuff. I'll be using SDL for sound & input and OpenGL for graphics. I'm thinking of using SDL_net but it seems kinda advanced.
> Should I use peer-to-peer or a client_server method for this game?.
Generally, a client-server method is easier. And, if you have 4 players, I'd definitely recommend you go client-server.
The best way to do this is to have a "dedicated" server running (maybe in a thread) on the host. If I were you, I'd also have the local client (the player who is hosting) connect to the local server, this makes things much simpler, since all the client code is the same whether you're a local or a remote player.
Sorry if that sounded condescending, but I don't know how good you are. :)
> Also, what library should I use if I'm new to network stuff. I'll be using SDL
> for sound & input and OpenGL for graphics. I'm thinking of using SDL_net but it
> seems kinda advanced.
I'd recommend using TCP/IP sockets without a library on top, but it's your call. SDL_net is probably easier though, but learning TCP/IP is more educational. Also, there are some nice and simple TCP/IP wrappers out there, I'd recommend you look into them.
.bas
Generally, a client-server method is easier. And, if you have 4 players, I'd definitely recommend you go client-server.
The best way to do this is to have a "dedicated" server running (maybe in a thread) on the host. If I were you, I'd also have the local client (the player who is hosting) connect to the local server, this makes things much simpler, since all the client code is the same whether you're a local or a remote player.
Sorry if that sounded condescending, but I don't know how good you are. :)
> Also, what library should I use if I'm new to network stuff. I'll be using SDL
> for sound & input and OpenGL for graphics. I'm thinking of using SDL_net but it
> seems kinda advanced.
I'd recommend using TCP/IP sockets without a library on top, but it's your call. SDL_net is probably easier though, but learning TCP/IP is more educational. Also, there are some nice and simple TCP/IP wrappers out there, I'd recommend you look into them.
.bas
.basprintf ( "And for the %dth time, I'm not American!", ++lIdiots );My homepage
I speak from my own experience alone, but I think that a peer-to-peer approach would be the easiest to implement and manage. In a multiplayer tetris game, I doubt you're concerned about hackers and the likes, so needing a server for authentication purposes isn't really an issue. You won't be relying on a specific player/server to keep the game going, so people can play fairly independant of who started the game. Since your playercount is at a maximum of 4, bandwidth shouldn't be an issue either.
You'd have much smaller data transfers if you only sent relevant block movement information. Specifying which key (of what, 5?) is only 1 byte, which is significantly less than repeatedly giving X/Y/rotation values on each piece that is dropping.
If it was me, I'd probably end up using winsock, just because I haven't played with any networking libraries all that much. RakNet and ENet seem to be the most popular as far as C/C++ goes, but I'm sure that there are others here that you guide you better. :)
Quote:
If p2p, should I pass the input between players or just the positions of the moving pieces?
You'd have much smaller data transfers if you only sent relevant block movement information. Specifying which key (of what, 5?) is only 1 byte, which is significantly less than repeatedly giving X/Y/rotation values on each piece that is dropping.
Quote:
Also, what library should I use if I'm new to network stuff. I'll be using SDL for sound & input and OpenGL for graphics. I'm thinking of using SDL_net but it seems kinda advanced.
If it was me, I'd probably end up using winsock, just because I haven't played with any networking libraries all that much. RakNet and ENet seem to be the most popular as far as C/C++ goes, but I'm sure that there are others here that you guide you better. :)
--Gauntlets of Recursion (+3) - My game development journal.My Recent Projects: [Meteorites] [Gundown] [Magma Duel] [Admiral Overalls] [Membrane Massacre]
SDL_net is just a basic low level wrapper around sockets anyways, and as an added plus side, would keep your game platform independent. Yay. If you learn SDL_net you should be able to pick up the equivalent winsock or berkeley sockets pretty easily.
I also found in my experience that what I initially thought would work well as p2p, ended up working out a lot easier as straight client-server, I found it difficult to synchronize when a few clients started joining, and I ended up just badly emulating a client server model anyways before I rewrote it. Your results may vary. :)
I also found in my experience that what I initially thought would work well as p2p, ended up working out a lot easier as straight client-server, I found it difficult to synchronize when a few clients started joining, and I ended up just badly emulating a client server model anyways before I rewrote it. Your results may vary. :)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement