- Java 8, Gradle
- Lightweight Java Game Library - Graphics / UI input
- Google Guice - Dependency injection
- Apache Log4j - Logging
- Junit, Mockito, AssertJ - Testing
- Docker - Deployment
EventBus and Network example drawing based on mouse-click and gunshot propagation.
Package names below specified relative to root ee.taltech.iti0200
.
menu
- outer wrapper loop for clientdi
- setting up modules and dependencies for selected game modeapplication
- initialization of modules per selected game mode, registering event handlers, main game loop and timer, cleanup on termination
Each game mode loads its own set of modules, for brevity S for Server, C for Client, P for Single-Player.
ai
- bot behaviour, creation and re-spawning (S/P)graphics
- rendering world, gui and entities (C/P)input
- capturing player keyboard and mouse input (C/P)network
- network thread management, syncing game and input events between the server and connected client(s) (S/C)physics
- motion, gravity, collisions, bounce and slide (S/C/P)
Package domain
defines the world, its layout, both living and non-living entities and equipment.
Contains event bus, game events and listeners.
During a multiplayer game the Server side is keeping the game state, clients send their user input updates and received both game events and position updates for other moving bodies in the server world (including other players).
Initial connection establishing is described on a separate page
- Server has 1 TCP port which is shared by a general
Registrar
thread + 2x per clientListener
&Sender
threads. - Server has a separate UDP port for each client which is shared by separate
Listener
&Sender
threads. - Client has 1 TCP port shared by separate
Listener
&Sender
threads. - Client has 1 UDP port shared by separate
Listener
&Sender
threads.
- At the start of a game loop, messages from the network threads are removed from their incoming queues and forwarded to event bus.
- Event listeners process those messages and stop their propagation.
- During the game loop the rest of the modules (namely
ai
,input
andphysics
) fire additional events. At the end of a game loop messages that are still alive and have an externalReceiver
are converted to network messages and passed on to appropriate outbox threads. - At this point the client side also includes player vector updates and the server side movable body updates to the outbox.
- Main thread on each side then sleeps to maintain a stable tick rate and outbound network threads send off the messages in their outboxes.
The ai
module tries to respawn new bots to world spawn locations to supersede the player count in the world.
Bot behaviour is driven by an adrenaline level which dictates the current executing goal (or general mood) and how sensory input affects the adrenaline level. Each goal brings a different general objective a bot tries to achieve. Adrenaline level goes down naturally if no further input is provided.
Bots have 4 sensors: visual, tactile, audio, damage
Bots moods:
- wander - no specific goal, easily agitated by damage, spotting a player and noise
- look for player - tries to navigate towards last seen player location or a close by gunshot
- panic - tries to move away for gunshot locations, also aggressive towards other bots
(see here for longer description)
World map structure is read from a jpg file.
Server recreates the world once all players have disconnected, or a player has won a match.