Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

ModelFactory Class Reference


Detailed Description

Knows how to create new models.

Definition at line 16 of file ModelFactory.h.

Static Public Member Functions

static CubecreateModel (const std::string &kind, const V2 &loc, const std::string &shape)
 Add model at scene.
static UnitcreateUnit (const std::string &kind)
 Create unit for driveable fish.
static CubecreateBorder ()
 Create special model, which will be used for outher space.


Member Function Documentation

Cube * ModelFactory::createBorder  )  [static]
 

Create special model, which will be used for outher space.

NOTE: hack border around field

Definition at line 138 of file ModelFactory.cpp.

00139 {
00140     Cube *border = new Cube(V2(-1,-1), Cube::FIXED, Cube::NONE, false,
00141             new Shape("X\n"));
00142     return border;
00143 }

Cube * ModelFactory::createModel const std::string &  kind,
const V2 loc,
const std::string &  shape
[static]
 

Add model at scene.

Parameters:
kind kind of item (e.g. "fish_big", "item_light", ...)
loc placement location
shape see Shape for format
Returns:
model
Exceptions:
LogicException for unknown kind
LayoutException when shape or location is bad

Definition at line 29 of file ModelFactory.cpp.

00031 {
00032     if (StringTool::startsWith(kind, "output_")) {
00033         return createOutputItem(kind, loc, shape);
00034     }
00035 
00036     Cube::eWeight weight;
00037     Cube::eWeight power;
00038     bool alive;
00039     createParams(kind, &weight, &power, &alive);
00040 
00041     Shape *newShape = new Shape(shape);
00042     Cube *model = new Cube(loc,
00043             weight, power, alive, newShape);
00044 
00045     return model;
00046 }

Unit * ModelFactory::createUnit const std::string &  kind  )  [static]
 

Create unit for driveable fish.

Parameters:
kind kind of item (e.g. "fish_big", "item_light", ...)
Returns:
new unit or NULL

Definition at line 101 of file ModelFactory.cpp.

00102 {
00103     Unit *result = NULL;
00104     if ("fish_small" == kind) {
00105         KeyControl smallfish;
00106         smallfish.setUp(SDLK_i);
00107         smallfish.setDown(SDLK_k);
00108         smallfish.setLeft(SDLK_j);
00109         smallfish.setRight(SDLK_l);
00110         result = new Unit(smallfish, ControlSym('u', 'd', 'l', 'r'), true);
00111     }
00112     else if ("fish_big" == kind) {
00113         KeyControl bigfish;
00114         bigfish.setUp(SDLK_w);
00115         bigfish.setDown(SDLK_s);
00116         bigfish.setLeft(SDLK_a);
00117         bigfish.setRight(SDLK_d);
00118         result = new Unit(bigfish, ControlSym('U', 'D', 'L', 'R'));
00119     }
00120     else if (StringTool::startsWith(kind, "fish_extra") ||
00121         StringTool::startsWith(kind, "fish_EXTRA"))
00122     {
00123         KeyControl extrafish;
00124         extrafish.setUp(SDLK_LAST);
00125         extrafish.setDown(SDLK_LAST);
00126         extrafish.setLeft(SDLK_LAST);
00127         extrafish.setRight(SDLK_LAST);
00128         result = new Unit(extrafish, parseExtraControlSym(kind));
00129     }
00130     return result;
00131 }


The documentation for this class was generated from the following files:
Generated on Wed Jun 1 09:55:56 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2