If you're interested in designing scenarios,
units, abilities, and so on, you probably only need to read all about
the files in data/
.
If you intend to develop GalaxyMage code, the files in
src/
are probably most important, but you'll probably
also want an idea of how the stuff in data/
works.
GalaxyMage.py
- the main GalaxyMage script. Imports src/Main.py
and executes the main()
function defined there.
*.txt
- top-level documentation files.
data/
directory has at least three subdirectories:
data/core/
, but are considered "optional". Basically,
this directory is for big data files (such as music) that we might
eventually want to bundle separately, so that players with slow
Internet connections can still download GalaxyMage reasonably quickly.
data/
. A campaign's directory contains the maps,
scenarios, and unit definitions that are used by that campaign. It may
also contain extra class definitions, abilities, sprites, sound
effects, music, and so on, that aren't available in the "core" data
files. GalaxyMage is currently distributed with one campaign, in
data/demo/
, that contains a few simple scenarios. If you
want to start on your own campaign, you should start by creating a
separate directory under data/
.
data/
directory are loaded by the code
in the file src/Resources.py
. Files are referred to by a
name that contains no subdirectories and no filename extension, such
as "cursor-click". The Resources
module takes care of
looking at all the right places to find the file. First, it looks in
the current campaign directory; then, it looks in the
extra
directory; finally, it looks in the
core
directory. Resources
knows what type of
file is being asked for, and uses that to determine which
subdirectories to look in and what filename extension to add. For
instance, sound files need to be in a subdirectory called
sounds
, and might end in either .ogg
or
.wav
. So if the current campaign is called "demo",
Resources
will look for the file "cursor-click" in the
following locations:
data/demo/sounds/cursor-click.ogg data/demo/sounds/cursor-click.wav data/extra/sounds/cursor-click.ogg data/extra/sounds/cursor-click.wav data/core/sounds/cursor-click.ogg data/core/sounds/cursor-click.wavThe first file found is the one that will be used. If none of these paths contains the desired file, an error will occur. This error will be handled gracefully if it's an optional sort of file, such as a sound or music file, but much less gracefully if it's something important, like a class definition or a map file. :)
I mentioned before that the Resources
knows to look in
the sounds
subdirectories to find sounds. Here's a list
of all the subdirectories for different types of data files.
data/*/abilities
data/*/classes
data/*/fonts
data/*/images
data/*/maps
data/*/music
.ogg
format.data/*/scenarios
data/*/sounds
.ogg
or .wav
format.data/*/text
data/*/textures
data/*/units
Main.py
- The main script. This is what runs when
GalaxyMage is executed. Parses command-line arguments, detects whether
needed libraries are installed, sets up logging, sets up the main
window, and starts the desired scenario.
Resources.py
- This file is the interface for loading all
sorts of data files off the disk. For more information, see the "How
data files are loaded" section above.
Sound.py
- Code for setting up pygame's mixer system and
playing sound effects on various channels.
Ability.py, Effect.py, Range.py
- These files all deal
with abilities, their ranges, and effects.
Battle.py
- The battle engine itself. Determines the turn
order, notifies the GUI or AI when it's time for the player or
opponent to act, applies movement and action commands, and checks
victory conditions.
Class.py
- This file deals with unit classes.
Faction.py
- Code relating to unit factions -- whether
different units are hostile, friendly, or neutral toward one another.
Light.py
- Defines lights and lighting environments.
Map.py
- Code relating to the battle map, including the
definition of the map itself, breadth-first search on the map,
calculation of movement ranges, calculation of nearest units to a
given point, and so on.
Name.py
- Picks random names for units based on their
genders.
Scenario.py
- Defines scenarios.
Unit.py
- Defines units.
Camera.py
- Keeps track of the current camera position
and has some utility functions for calculating stuff based on the
camera position. For instance, it can sort sprites in back-to-front
order so that they are alpha-blended properly.
Clock.py
- Utility code for an FPS clock.
Cursor.py
- Code for moving around the on-screen cursor
-- the blue square on the battle map. This is where the player chooses
where his units move and attack.
Geometry.py
- Utility geometry routines.
GLUtil.py
- Contains a bunch of OpenGL convenience
functions... rendering text to a texture, drawing cubes and sprites on
screen, and so on.
MainWindow.py
- The main window. Contains code for
initializing the pygame/PyOpenGL systems, handling window resize
events, handling some other events, and counting/limiting FPS. The
MainWindow doesn't actually draw anything -- it delegates
responsibility for that to another object, such as ScenarioGUI.
ScenarioGUI.py
- A delegate for displaying an entire
scenario. Draws the map, cursor, unit sprites, battle menus, and so
on.
Sprite.py
- Definitions of sprites, including unit
sprites, on-screen text displayers, and menus.
tools
contains the scripts used to build the Windows and
Macintosh binaries when we do an official release.