Tidal Tussle

A small game demo about fighting enemies off of a ship, utilising custom UDP networking with SDL

University grade: 95%
Fish
ServerManager.cpp
void ServerManager::Send(bitset<32> headerData, vector<bitset<8>> packetData, IPaddress address, int length) { // Allocate packet sized to the data UDPpacket* packet = SDLNet_AllocPacket(length); if (!packet) { std::cerr << "SDLNet_AllocPacket: " << SDLNet_GetError() << std::endl; SDLNet_UDP_Close(socket); SDL_Quit(); } // Copy header to start of packet data memcpy(packet->data, &headerData, 4); // Iterate, copying each byte for (int i = 0; i < packetData.size(); i++) { memcpy(packet->data + 4 + i, &packetData.at(i), 1); } packet->len = length + 1; packet->address = address; if (SDLNet_UDP_Send(socket, -1, packet) == 0) { std::cerr << "SDLNet_UDP_Send: " << SDLNet_GetError() << std::endl; } }


Tidal Tussle was a game I made for my third year Multiplayer Games Development university module. I was tasked with creating a game using either Unity, Unreal, or C++ with SDL that implemented networking technologies. I decided to use C++ with SDL and first researched different networking protocols available to me. This research led me to choose UDP over TCP as my protocol. I recieved a 95% grade for this project and its associated report.



Protocol decision — UDP vs TCP

UDP ✓ chosen

Lower latency — no handshake overhead per packet
TCP features can be layered on top as needed
Requires more implementation work for stable, reliable systems
Best fit for a real-time action game
vs

TCP

Built-in message acknowledgement and ordering
Easier to use out of the box — less to implement
Slower — confirmation round-trips add latency to every message