How dickbalaska/slyther works
1. The Client – a full-featured game client that incorporates game logic, rendering (with both LWJGL 2 and LWJGL 3 variants on different branches), user interfaces (menus, in-game GUI, snake customizations, etc.), local database capabilities (using Hibernate for game statistics and other stored data), and recording/replaying functionality.
2. The Server – a game server that manages network communications, game state updates, message dispatching, and a primitive built‐in server which should generally be avoided in favor of proper server deployment. It includes modules for handling client connections, game simulation (including entity management for snakes, food, and board sectors), and monitoring.
3. The Shared Library (slytherlib) – which encapsulates the common game logic, shared message protocols, network abstractions, and core data models (e.g., entities, configurations, and utilities) that are used by both the client and the server.
Main Components and Their Responsibilities
• Client Module:
• GUI and User Interface Elements (found under client/gui and client/gui/element)
• Game Logic and Input Handling (client/game, client/controller)
• Network Management (client/network, handling both incoming messages from the server and sending messages to it)
• Database Management (client/db with Hibernate integration – Database, DatabaseImpl, GameStatistic, etc.)
• Rendering and Resource Management (client/render, textures, and resource files)
• Game Recording and Replay (client/recording)
• Server Module:
• Network Communication and Message Handling (server/network, server/message/...)
• Game Simulation and Entity Management (server/game and server/game/entity)
• Connection and Client Monitor Management (server/server components such as ConnectedClient, ServerNetworkManager, ServerMonitorManager)
• Shared Library (slytherlib):
• Common data structures and game logic (slytherlib/game, slytherlib/game/entity)
• Shared networking classes and messaging protocols (slytherlib/network and its message sub-packages)
• Common utilities and configuration management shared between client and server
Relationships and Interactions
• The Client communicates with the Server over a network protocol that is defined in both the client and server packages. The messaging system is implemented in a bidirectional way, with messages for client-to-server communication (e.g., MessageStartLogin, MessageSetTurn) and server-to-client (e.g., MessageNewFood, MessageUpdateMap).
• The Client uses the shared library (slytherlib) for common game functions – both in terms of rendering game entities and following the protocol for communications.
• The Server similarly relies on slytherlib for implementing the game rules, converting messages received from clients into game state updates, and broadcasting messages to all connected clients.
• The Database integration (using Hibernate) on the client (and parts on the server) is responsible for maintaining historical game statistics, user configurations, and possibly other persisted data.
Architectural Patterns and Design Principles
• Separation of concerns is evident: the presentation layer (GUI/rendering), networking, game logic, and data persistence are all housed in separate packages.
• The use of client and server modules resembling a client–server architecture, with clear responsibilities and a shared protocol defined in the common library.
• MVC-like organization within the client module:
– Controllers (in client/controller) handle input and game state changes.
– Views (GUI components in client/gui) display the game.
– Model (game entities and database objects under client/game/entity and client/db) represent internal game state.
• Standard networking abstraction: message classes, handlers, and managers on both sides make it clear that the design is modular and allows for extensibility.
Technologies and Frameworks Highlighted
• Java (language) and Gradle (build system)
• LWJGL 2 and LWJGL 3 (for game rendering, depending on branch)
• Hibernate (for database persistence and object–relational mapping)
• Custom networking library code (inside slytherlib and respective network packages in client and server)