Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

Map Namespace Reference


Compounds

struct  WorldMap
 Holds dimension data for the overhead view. Basically creates a bounding rectangle that should contain ALL units and structures in the game. Failure to keep a unit or structure inside this bounding rectangle will cause problems with the AI. More...


Functions

WorldMap createWorldMap (string &line)
 creates a world map that contains bounds information for the map.

Vec3D getColorVec3D (string &color)
 , converts a color name to the Vec3D color

MilitaryUnitcreateUnit (string &line)
 Create a new military unit.

CitycreateCity (string &line)
 Create a new City.

const string TOK_COMMENT ("//")
 Tokens used in map file parsing.

const string TOK_MAP_DIMS ("MAP DIMS:")
const string TOK_CREATE_UNIT ("CREATE UNIT:")
const string TOK_CREATE_CITY ("CREATE CITY:")
const string TOK_LIGHT_TANK ("LIGHT_TANK")
const string TOK_NEUTRAL ("NEUTRAL")
 Denotes the owner of a unit or structure.

const string TOK_BLACK ("BLACK")
const string TOK_RED ("RED")
const string TOK_GREEN ("GREEN")
const string TOK_BLUE ("BLUE")
const string TOK_CYAN ("CYAN")
const string TOK_MAGENTA ("MAGENTA")
const string TOK_YELLOW ("YELLOW")
const string TOK_WHITE ("WHITE")


Function Documentation

City * Map::createCity string &    line
 

Create a new City.

Parameters:
line the initial values for the constructor. the data MUST appear in the order its listed in the constructor.
Returns:
the newly constructed unit.

Definition at line 70 of file Map.cpp.

References Vec3D.

00071   {
00072     istringstream is(line);
00073     float x,y,z;
00074     string color;
00075     is >> x >> y >> z >> color;
00076     // cities will be assigned a color upon game creation
00077     return new City(Vec3D(x,y,z), 0);
00078   }

MilitaryUnit * Map::createUnit string &    line
 

Create a new military unit.

Parameters:
line the initial values for the constructor. The first token MUST be the unit type following that the data MUST appear in the order its listed in the constructor.
Returns:
the newly constructed unit.

Definition at line 55 of file Map.cpp.

References getColorVec3D(), and Vec3D.

00056   {
00057     istringstream is(line);
00058     string type;
00059     float x,y,z;
00060     string color;
00061 
00062     is >> type >> x >> y >> z >> color;
00063 
00064     if( type == TOK_LIGHT_TANK )
00065                 return new LightTank(Vec3D(x,y,z), GameState::findPlayer(getColorVec3D(color)), DEFAULT_LIGHT_TANK_SIZE );
00066     else
00067       throw Error("Map parse error  Map::createUnit Invalid Unit Type");
00068   }

WorldMap Map::createWorldMap string &    line
 

creates a world map that contains bounds information for the map.

Parameters:
line dimensions of the map. the format is as follows: START_X_COORD START_Y_COORD END_X_COORD END_Y_COORD GRID_WIDTH GRID_HEIGHT

Definition at line 24 of file Map.cpp.

References Map::WorldMap::bounds, Map::WorldMap::gridHeight, Map::WorldMap::gridWidth, Map::WorldMap::height, Rect::setBounds(), Vec2D, and Map::WorldMap::width.

Referenced by Overhead::loadMap().

00025   {
00026     WorldMap wm;
00027     istringstream is(line);
00028     
00029     Vec2D ul, lr;
00030 
00031     is >> ul.x >> ul.y >> lr.x >> lr.y >> wm.gridWidth >> wm.gridHeight;
00032     wm.bounds.setBounds(ul, lr);
00033     wm.width = lr.x - ul.x;
00034     wm.height = lr.y - ul.y;
00035 
00036     return wm;
00037   }

Vec3D Map::getColorVec3D string &    color
 

, converts a color name to the Vec3D color

Definition at line 41 of file Map.cpp.

References Vec3D.

Referenced by createUnit(), and HUD::init().

00042   {
00043     if( color == TOK_NEUTRAL) return Globals::NO_OWNER;
00044     else if( color == TOK_BLACK) return Colors::black;
00045     else if( color == TOK_BLUE ) return Colors::blue;
00046     else if( color == TOK_CYAN ) return Colors::cyan;
00047     else if( color == TOK_GREEN ) return Colors::green;
00048     else if( color == TOK_MAGENTA ) return Colors::magenta;
00049     else if( color == TOK_RED ) return Colors::red;
00050     else if( color == TOK_WHITE ) return Colors::white;
00051     else if( color == TOK_YELLOW ) return Colors::yellow;
00052     else throw Error("Map parse error  Map::getColorVec3D Invalid Color");
00053   }

const string TOK_BLACK "BLACK"    [static]
 

const string TOK_BLUE "BLUE"    [static]
 

const string TOK_COMMENT "//"    [static]
 

Tokens used in map file parsing.

const string TOK_CREATE_CITY "CREATE CITY:"    [static]
 

const string TOK_CREATE_UNIT "CREATE UNIT:"    [static]
 

const string TOK_CYAN "CYAN"    [static]
 

const string TOK_GREEN "GREEN"    [static]
 

const string TOK_LIGHT_TANK "LIGHT_TANK"    [static]
 

const string TOK_MAGENTA "MAGENTA"    [static]
 

const string TOK_MAP_DIMS "MAP DIMS:"    [static]
 

const string TOK_NEUTRAL "NEUTRAL"    [static]
 

Denotes the owner of a unit or structure.

const string TOK_RED "RED"    [static]
 

const string TOK_WHITE "WHITE"    [static]
 

const string TOK_YELLOW "YELLOW"    [static]
 


Generated on Wed Apr 23 05:52:17 2003 for Modern Warfare by doxygen1.3-rc2