Archived

This topic is now archived and is closed to further replies.

elgransan

My Tetris Game Design

Recommended Posts

Hello, Im working on a MultiPlayer tetris game (The Santris Game) and Im not really sure that Im in the correct way in syncronization. This is the situation. I have a CGame class thats inherits from CWin, CNet Then I have a CBoardList where I can append CBoards instances. My problem is that Im not realy sure on how to comunicate between the players, I think i have to send the key pressed to the server player and then it send it to the rest of players. How many sync problems can I have? I know two: timing and lost of data or bad parsered(parser is a verb?, I dont know). How can control both of them? (and the others that I dont know) Thanks to all Santiago From Argentina

Share this post


Link to post
Share on other sites
Actually I am looking to extend my tetris game to multiplayer also. I am pretty sure if you only send key presses, you will easily get out of synch. When I play tetris with my roomates on a nintnedo emulator over cable modem (average ping 30ms) the game almost always goes out of synch at some point.

Suppose I push down down left right. Since all of the packets may not arrive, or may arrive out of synch, the other player might recieve down left right, and now the two computers are out of synch.

The way that I am thinking of implemementing this is to send all of the board data + the current piece data + number of lines to add + a timing signal at some regular interval based on the current latency settings. Note that all of this data is very small if you use only one byte or less per square. I haven''t decided yet whether or not to interpolate between timing messages, or to only allow board updates on timing marks. This will likely be based on current latency settings. I think you need updates at least every 250ms or else the game will feel slow.

I will post more in a week or two, when I have something running.

Share this post


Link to post
Share on other sites
Maybe you could try using some kind of error checking. Keep the packets in some sort of buffer and send a value with the packet based off the packet number that the receiver can decrypt. If the receiver first gets packet 50 then gets packet 52 because 51 was lost, it knows about it and can request packet 51 from the server (because it is all in a buffer =).
Just an idea anyway...

-BronYrAur
aka "CodeSourcerer"

Share this post


Link to post
Share on other sites
quote:
Original post by elgransan
I'm not really sure that I'm in the correct way in syncronization.

I think i have to send the key pressed to the server player and then it send it to the rest of players.


Basically, that's right. Although I think there is a better way.
quote:

How many sync problems can I have?
I know two: timing and lost of data or bad parsered(parser is a verb?, I dont know).


You shouldn't need to worry about data being bad, the network system should make sure that any bad data is resent. However, you do need to worry about timing.

The basic idea is that, every so often, the server will need to tell the clients about the parts of the board that have changed. I don't know how your game plays, but I assume that a board has only one piece moving on it at a time.

Each time the player on one client presses a key and rotates or moves his/her piece, that will be relayed to the server. Now, the best way to go from here, it seems to me, is for the server to tell each client where the piece is, and where it is facing.


// Active piece has moved to (x,y) and is facing (angle)
SendToClient(client, PIECE_MOVE, piece.x, piece.y, piece.angle);


This means that the pieces won't 'drift' away from their correct location, as could happen if you relayed only keypresses.

Each time a piece 'lands' somewhere, you can simply send a message that indicates that this has happened, and then send another message that tells it about the new piece.


// Active piece has moved to (x,y), is facing (angle) and has
// now stopped - add it to the stationary blocks
SendToClient(client, PIECE_STOP, piece.x, piece.y, piece.angle);
// Make a new piece at (x,0), with the shape (shape).
SendToClient(client, PIECE_NEW, piece.x, piece.shape);


I think that this method should make it uneccesary to send the entire board, at any time.
quote:

How can control both of them? (and the others that I dont know)


I'm not sure what you mean by that, could you explain it further?

All your bases belong to us

Edited by - Mayrel on November 2, 2001 2:46:25 PM

Edited by - Mayrel on November 2, 2001 2:47:06 PM

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Thanks to all!

My game is fully object oriented, I can create a new board only doing:

myboard = new Board;

And I can assign keys to any board and the cooperative mode (Two players in the same board).

Unless I was thinking a lot in yours oppinions, I dont think that the invective method can be applied to my game because I have to put my Board class in the recycled!!!
And if I have a cooperative game I can´t send all the board state between the player because both of them can modify the same board in the same time.

Mayrel I think you were correct, this is a good way to go.

But Im a little confused with the BronYrAur oppinion, Is posible to lost a packet if Im using TCP?
Is possible too to receive the packets mixed, for instances If I send down, left, right (like invective said) can I receive left, rigth, down??


well, Im writting with the few words that I know, Its very dificult to explain the matter in this way... Nobody speake in Spanish?

Gracias - Thank
Chau - Bye

Santiago


Share this post


Link to post
Share on other sites