Subatomic

Subatomic is a networked game project revolving around the utilization of REST, NodeJs, MongoDB, UDP, Qt, Google Protobuf, Python and Unity. The project itself is a combination of three individually purposed projects.

Subatomic Back-End

nodejs-logo_tn
mongodb-logo-svg

The first project is the Subatomic Back-end project. This utilizes a RESTful implementation through Nodejs where persistent data is stored in MongoDB. digital-ocean-logo-4x3The server that hosts this implementation lives on a Digital Ocean droplet. The purpose of this project is to allow users to register their accounts to allow for logging back in or out, create in-game player characters as well as other future applications that aren’t yet implemented in this project. Such as saving inventory, last location in the world for particular player objects as well as other things relating to the state of the game world. The saving and retrieval of persistent data is the driving force for this project’s purpose within Subatomic.

The following gif represents the registration process, which sends a request to the Digital Ocean server for creating a new user that is stored in the MongoDB that can be logged in and out with during future sessions:
registrationdemonstration
This gif represents the player ship creation process that stores within the MongoDB that can be used within the Subatomic game world, construction sends a request for storing the player ship in the player’s mongodb table:
constructiondemonstration
The logging back in of the registered user is demonstrated in this gif, where they can utilize their created player ships, logging in sends a request to the back-end server for the player ship objects that the user created in prior sessions:
logindemonstration

Subatomic Server

The second project is the Subatomic Server project. This is the heart of the project in terms of what allows for players to interact with each other. This provides simulation of various requested game events, packet sending, packet receiving, packet tracking, message logging and data tracking of the game world and connected clients. In addition, the sending, receiving and game simulation occur in separate threads to allow for continual data streaming and processing of their own purposes.

The following gif shows a demonstration of the Subatomic Server in-action:
subatomicserverdemonstration

qtcreatorThis project is separated into three individual sub-projects within itself. Allowing for organization and separation of particular purpose. The project as a whole is wrapped around the Qt platform and compiled using mingw. The purpose for this choice has been to allow for a smoother transition to a Unix platform in the future.

Subatomic Protocol Buffers

protobufThe first sub-project is the Subatomic Protocol Buffers sub-project. This utilizes Google’s Protobuf API for generating message code that I send across the wire using UDP. Here is an example of my utilization of the .proto raw messages before they are regenerated into their corresponding .cpp, .h & .cs files:

python-logo-notext-svgI store these messages in a ProtocolBuffers folder within their corresponding sub-folders. After a new message or modification of an older message I run a python script that recursively collects the .proto files, compiles them through Google Protobuf’s protoc.exe interpreter for output as .cpp & .h into this sub-project. These message are also outputted as .cs for utilization in the Subatomic Game Client Unity project. One of the coolest aspects of this iteration process is how quickly it is to add a new message or modify an existing message. From here this sub-project is compiled into a shared library for usage in the other Subatomic Server sub-projects.

Subatomic Server Lib

The second sub-project is the shared library where the generic server code is implemented. The features include:

  1. The implementation and concept of the server, client and client manager.
  2. Received message registration and threaded receiving & dispatching.
  3. Threaded sending of messages.
  4. Packet tracking implementation for making sure we keep trying to send messages that need acknowledgment.
  5. Client and Server logging to keep track of messages that have been sent and received.
  6. Custom command interface registration.

Subatomic Interface

The third sub-project is the particular implementation for the Subatomic Game and client interaction. Within here the Qt interface is created, implemented and utilized. Where custom Subatomic Server Lib interfaces are used to define the messages that are used for the Subatomic Game. Such as the custom definition for when a player has sent a ping to the Subatomic Server from within the Subatomic game, the PacketReceiveHandler is defined for that message:

Where these messages are registered to the PacketHandler:

The game world specific pieces are also simulated here to allow for the server side to maintain the core state of the world. Such as when a player requests to shoot a projectile, the server will create a projectile and simulate it’s location and determine if it collides with another game client.

Subatomic Game Client

unity-logo-whiteThe third project is the Subatomic Game Client Unity project. This has served mainly as my testing area during the development of the Subatomic Server and utilization of the Subatomic Back-End. The client communicates over the network with the back-end for persistent data storage, and through the Subatomic Server for game specific aspects. Such as telling the server about our Transform information, if we are shooting, connecting or disconnecting and other game related confirmations and messages.

This client utilizes Google Protobuf in the form of outputted c-sharp files for sending message definitions over UDP to the Subatomic Server. The awesome bit here is the interchangeability of being able to write a custom .proto file and having it be outputted as both .cpp, .h & .cs for utilization on whichever end. This is how I’m sending these protobuf messages on the c-sharp side:

gamedemonstration
The game client admittedly still leaves a lot to be desired. My goal for the future is to re-work the game client to revolve around a more three dimensional world of collaboration which will allow for uncovering and solving new problems both server and client side.

Leave a Reply

Your email address will not be published.