Programmer's guide
Up Game Manager Comm Manager Technology Techniques Objects & Classes Performance statistics

Major programming features

MFC based.
Heavy use of C++ features
Encapsulation
Inheritance
Dynamic binding
Exceptions
Polymorphism
Uses DirectPlay
IDirectPlay2 interface - multiplayer communication infrastructure.
Uses DirectSound
IDirectSound Interface - smooth mixing of sound effects.
Multithreaded
Main UI thread
Game manager worker thread
Comm. manager worker thread
Uses DIBs and the DrawDIB API (from WFW) for animations.
The Game Manager
Main game loop
Manages list of objects
The Comm Manager
Communication protocol
Synchronization.
Message packing and unpacking
A timer mechanism - time synchronization using smoothed averages.
Automatic and random map generation
Accepts a seed and difficulty level and creates a random map
All the machines see the same map
No closed (unreachable by tank) areas
Image manager
Lists of images
Animations (frame rates, cycles etc)
Transparency
Collision detection
Overlayed images
Image offsets.
Smart queues for inter-thread messaging support.
Bit-field packing of network messages for optimum bandwidth usage.
Keyboard manager - Mapping virtual keys into maneuver sets of local tanks.
Animated user interface
Dialog buttons
Animation controls

Data-flow diagram

dataflow.gif (28706 bytes)

 

legend.gif (8390 bytes)

Optimization techniques

Communication optimization

Bit-wise packing of all messages for smaller packet size.

Using byte alignment for network packages while maintaining double-word alignment for internal messages.

Sending compact check-sums periodically (from clients to host) and receiving updates (from host to clients) only when a mismatch passes a variable threshold - preserving bandwidth.

Each tank sends its maneuver over the network only when it changes (e.g. when a tank moves in a straight line, only two messages are sent - when it starts moving and when it stops moving).

Rendering optimization

Using double-buffering for smooth animation, preventing flickering.

Every frame, only the smallest rectangle that contains the objects that changed their appearance since the last frame, is drawn to the screen.

Using the DrawDIB library bypasses the GDI, resulting in better screen hardware access.

Memory optimization

All messages (internal and network) have the same structure size. We use pool-allocation management techniques to minimize heap calls (malloc / free) and prevent fragmentation.

 

Back Home Next