|
TileMagic: Snippets
Functions that have been developed since v2.02:
- SJ_TileMagic_CoverLargeArea
SJ_TileMagic_CoverLargeArea
While TileMagic works best when used to cover small areas, some people can't resist trying to flood a 32x32 tile area. Unfortunately this falls foul of the 20K Rule and causes a TMI Error. So if you absolutely must flood an area larger than about 19x19 you can now use the *CoverLargeArea method.
Note *CoverLargeArea was added to TileMagic v2.03 however
the rotation control was omitted (because the previous version on this page
didn't have it and I copied it straight into sj_tilemagic_i). The following
revised version will be appearing in TileMagic v2.04:
// Covers oArea with TileMagic tiles in quarters to avoid TMI errors. The tiles // have a vertical offset of fZ modified by nTile's internal offset unless using // bNormalise. // NOTE: if you have to use this function then try to restrict using it to the // OnModuleLoad event as it may cause a very obvious pause in the game. // - oArea: area to be tiled // - nTile: SJ_TILEMAGIC_ORDINARY_* / SJ_TILEMAGIC_FEATURE_* constant // - fZ: height of the tile // - bNormalise: TRUE (to compensate for tile's internal offset) or FALSE // - nRotation: SJ_ROTATION_* constant void SJ_TileMagic_CoverLargeArea(object oArea, int nTile, float fZ=0.0, int bNormalise=TRUE, int nRotation=0);
void SJ_TileMagic_CoverLargeArea(object oArea, int nTile, float fZ=0.0, int bNormalise=TRUE, int nRotation=0)
{
// get area dimensions
int nCols = SJ_GetAreaWidth(oArea);
int nRows = SJ_GetAreaHeight(oArea);
// get the mid-point of each (rounded down)
int nCol = nCols / 2;
int nRow = nRows / 2;
// cover each quarter of the area using AssignCommand to give each call to
// CoverRange call a separate instruction count and thus avoid a TMI
// NOTE: use (nCols - nCol) and (nRows - nRow) to handle areas where height
// and/or width is an odd number of tiles, e.g. 25x25.
AssignCommand(OBJECT_SELF, SJ_TileMagic_CoverRange(oArea, nTile, 0, 0, nCol, nRow, fZ, bNormalise, nRotation));
AssignCommand(OBJECT_SELF, SJ_TileMagic_CoverRange(oArea, nTile, nCol, 0, (nCols - nCol), nRow, fZ, bNormalise, nRotation));
AssignCommand(OBJECT_SELF, SJ_TileMagic_CoverRange(oArea, nTile, 0, nRow, nCol, (nRows - nRow), fZ, bNormalise, nRotation));
AssignCommand(OBJECT_SELF, SJ_TileMagic_CoverRange(oArea, nTile, nCol, nRow, (nCols - nCol), (nRows - nRow), fZ, bNormalise, nRotation));
}
|