Purple Martians
Technical Code Descriptions
Project Organization
Source files
Source files
The source files are all in a common directory and all compile to a single executable.
They are all *.cpp even though I mostly only use straight C.
Files that begin with 'e_' are for the level editor. (which at one point was a seperate exe)
e_bitmap.cpp
e_editor_main.cpp
e_editor_zfs.cpp
e_enemy.cpp
e_fnx.cpp
e_glt.cpp
e_item.cpp
e_lift.cpp
e_object_viewer.cpp
e_pde.cpp
e_sliders.cpp
e_visual_level.cpp
Files that begin with 'z_' are for the game.
z_bullets.cpp
z_config.cpp
z_control.cpp
z_enemy.cpp
z_file.cpp
z_fnx.cpp
z_item.cpp
z_lift.cpp
z_log.cpp
z_logo.cpp
z_loop.cpp
z_main.cpp
z_map.cpp
z_menu.cpp
z_player.cpp
z_screen.cpp
z_screen_overlay.cpp
z_sound.cpp
Files that begin with 'n_' are for netgame.
n_client.cpp
n_network.cpp
n_packet.cpp
n_server.cpp
The function 'main' is found in the file z_main.cpp.
Also found in z_main.cpp:
- command line argument parsing and processing
- initial setup, loading allegro and add-ons
- the main game menu
- a huge pile of global variable definitions
I only have one header file: 'pm.h' that is included in every source file.
It contains extern declarations of all the global variables definied in zmain.cpp.
It also contains function prototypes for every function in the project.
I know this is not "good programming style" and I have tried to reduce the number of
globals wherever possible. However, sometimes I just need to have a variable visible
in many places, and any other solutions I could think of to avoid this, end up being more
convoluted and non-intuitive.
In the file 'z_config.cpp' I load and save variable to the configuration file 'pm.cfg'.
In the file 'z_sound.cpp' I set up and process sound effects and theme music.
In the file 'z_screen.cpp' I create the display and bitmaps, as well as rebuild them after screen changes.
In the file 'z_file.cpp' are the functions to load the tilesets and levels.
In the file 'z_loop.cpp' is the main game loop.
In the file 'z_control.cpp' is the event loop processing, and also all input and game controls
The in game objects fall into 5 classes and are processed in:
players - z_player.cpp
enemies - z_enemy.cpp
items - z_item.cpp
lifts - z_lift.cpp
bullets - z_bullets.cpp