I have a question about what the stream might look like from client to server and back. I would like to make use of SDL NET, so it basically takes care of most of the low level stuff.
I looked at this example at gpwiki.org
Here is the loop
while (!quit)
{
/* Wait a packet. UDP_Recv returns != 0 if a packet is coming */
if (SDLNet_UDP_Recv(sd, p))
{
printf("UDP Packet incoming\n");
printf("\tChan: %d\n", p->channel);
printf("\tData: %s\n", (char *)p->data);
printf("\tLen: %d\n", p->len);
printf("\tMaxlen: %d\n", p->maxlen);
printf("\tStatus: %d\n", p->status);
printf("\tAddress: %x %x\n", p->address.host, p->address.port);
/* Quit if packet contains "quit" */
if (strcmp((char *)p->data, "quit") == 0)
quit = 1;
}
}
In this example, the server just prints the incoming packet. My first question is this. Do I understand it correctly, that if a packet contains
->quit, then it simply quits? What I mean is, is it simply a message "quit"?
To better ask my question, maybe someone can clarify this.
If I use the above code, but instead of printing it to the screen I make use of the packets, then what would be a message to move a 2D Tile, up, down, left or right.
In other words, I would like to setup a server and client in SDL. They both load a 10x10 tile map. the server would put a monster in tile (0,0)
and the client would put a player in tile (9,9). So if the server moves the monster right in real time, and the player moves up in real time, what would the back and forth messages look like?
I apoligize, but I might not have the concept down correctly yet. If anyone has a simplified explanation, tutorial, or source example in C++, I would really appreciate it if you can share it?
The goal is a tile based multiplayer game. Perhaps 5 - 10 players, with a larger tile map of course.