Sunday, 2 November 2014

Game Engines Blog 3

(In game screenshot)

These past few weeks I have been playing around with more texture backing and global illumination. And seeing how our maps will be static, this made sense for us to bake some of the lighting effects. I think the end result looks pretty nice, it gives a more realistic look to our levels. 

I've added some bloom post processing effect to our game as well. This was done by creating an FBO with color and depth attachments along with a post processing shader that works on a single texture. 

(In game screenshot)

Our gameplay will have a heavy focus on multiplayer, so I wanted to have a quick way to test it early. What I did was implement a familiar library called SDL_Net, which does very simple server to client communication with TCP/IP packets.

if (isOnline)
net->recieve(&opponent, &netPlayer);

I've set up a simple server that will assign IDs to each game client. The clients have 2 functions, Send and Recieve, once the server receives a packet, it will send out the packet to other clients that isn't the sender. This is a very basic form of networking and can work through LAN connection by assigning the client's with the appropriate IPv4 address.

Each packet data simply contains player data stitched into a single char array format then sent to the server application.

math_t::Vec3f pos = p->model.position;

//this packs data into a single char array (tmp)
// 1 = packet id, %d = ID, %f positionX, %f positionY, %f positionZ, %1f rotation_angle
//%d for int, %f for float, %1f for double
sprintf(tmp, "1 %d %f %f %f %lf \n", p->getID(), pos[0], pos[1], pos[2], p->rotation_angle);

 int size = 0;
int len = strlen(tmp) + 1;

while (size < len)
size += SDLNet_TCP_Send(connection, tmp + size, len - size);

And that's the current state of our game. We plan to use this to polish our gameplay and test various forms of PVP game types in the near future.

No comments:

Post a Comment