#include <SAM.h>
Collaboration diagram for gedi::SAM:
Public Member Functions | |
SAM (void) | |
SAM (gedi::Int32 iMapBlkWidth, gedi::Int32 iMapBlkHeight, gedi::Int32 iTileWidth, gedi::Int32 iTileHeight) | |
void | Update (void) |
void | Render (void) |
gedi::Int32 | GetCollideBlkNumber (gedi::Int32 iX, gedi::Int32 iY) |
gedi::Int32 | GetAnimationNumber (gedi::Int32 iX, gedi::Int32 iY) |
gedi::Int32 | GetXStart (void) |
gedi::Int32 | GetYStart (void) |
gedi::Int32 | GetXEnd (void) |
gedi::Int32 | GetYEnd (void) |
gedi::Int32 | GetWidth (void) |
gedi::Int32 | GetHeight (void) |
gedi::Int32 | GetMapWidth (void) |
gedi::Int32 | GetMapHeight (void) |
gedi::Int32 | GetBlkWidth (void) |
gedi::Int32 | GetBlkHeight (void) |
void | LoadImage (LPSTR lpszFilename) |
void | SetMappy (const BLKSTR pBlkProps[], const ANISTR pAniProps[], const short pMapProps[], const int pAniSeqs[]) |
gedi::Bool32 | Scroll (gedi::Int32 iXDelta, gedi::Int32 iYDelta) |
void | ScrollBlock (gedi::Int32 iXDelta, gedi::Int32 iYDelta) |
void | SetDimensions (gedi::Int32 iMapBlkWidth, gedi::Int32 iMapBlkHeight, gedi::Int32 iTileWidth, gedi::Int32 iTileHeight) |
void | SetViewDimensions (gedi::Int32 iXViewWidth, gedi::Int32 iYViewHeight) |
The key idea underlying this class is the notion of a viewport. A viewport is a window into the map. A games scrolls the map by invoking the Scroll method for smooth, pixel scrolling or ScrollBlock for tile scrolling.
The default viewport is 640 x 480 pixels. The SetViewDimensions method changes the size of the viewport. However, the game must make sure that the host GUI matches this setting.
The class has been thoroughly tested only for maps with non-animated tiles and LOOPF tiles. It has also been tested only for maps with 640 x 480 view ports.
The class interfaces indirectly to Mappy through its "text" export file. However, the class "plays" only single layers, although Mappy can generate multiple layers.
Also, Mappy can generate one backgroud tile and up to three forground tiles. gedi::SAM does not currently support this feature. It only renders the background file. If you need to rendered layered tiles, you'll have to build it in the image file.
To interface to Mappy, you'll have to export a text file in Mappy and include the .h file in the game. The export options (File >> Export as text) on the Textfile dialog are as follows:
With these settings you can then just invoked the SetMappy method with the Mappy data structures. That is,
...SetMappy(&X_blockstr[0], &X_animstr[0], &X_map0[0], &X_animseq[0])
where X is the name prefix given in Mappy.
gedi::SAM::SAM | ( | void | ) |
Constructor.
gedi::SAM::SAM | ( | gedi::Int32 | iMapBlkWidth, | |
gedi::Int32 | iMapBlkHeight, | |||
gedi::Int32 | iTileWidth, | |||
gedi::Int32 | iTileHeight | |||
) |
Constructor.
iMapBlkWidth | Map width in blocks (or tiles). | |
iMapBlkHeight | Map height in blocks (or tiles). | |
iTileWidth | Tile width in pixels. | |
iTileHeight | Tile height in pixels. |
void gedi::SAM::Update | ( | void | ) |
Updates the map, specifically, the timer and any animations. If there are no animations this method should still be called.
void gedi::SAM::Render | ( | void | ) |
Render the map.
gedi::Int32 gedi::SAM::GetCollideBlkNumber | ( | gedi::Int32 | iX, | |
gedi::Int32 | iY | |||
) |
Get the block index, if the block has collision properties set. The block index is the index in the Mappy BLKSTR array. If any one of the collision properties are set, namely, top left, top right, bottom left, or bottom right for world (pixel) coordinate, iX, iY, the method returns a non-zero block index. Otherwise, it returns zero.
iX | World X pixel coordinate. | |
iY | World Y pixel coordinate. |
gedi::Int32 gedi::SAM::GetAnimationNumber | ( | gedi::Int32 | iX, | |
gedi::Int32 | iY | |||
) |
Get the block index, if the block is an animated block.
iX | World X pixel coordinate. | |
iY | World Y pixel coordinate. |
gedi::Int32 gedi::SAM::GetXStart | ( | void | ) | [inline] |
Get viewport X start .
gedi::Int32 gedi::SAM::GetYStart | ( | void | ) | [inline] |
Get viewport Y start .
gedi::Int32 gedi::SAM::GetXEnd | ( | void | ) | [inline] |
Get viewport X end .
gedi::Int32 gedi::SAM::GetYEnd | ( | void | ) | [inline] |
Get viewport Y end .
gedi::Int32 gedi::SAM::GetWidth | ( | void | ) | [inline] |
Get viewport width.
gedi::Int32 gedi::SAM::GetHeight | ( | void | ) | [inline] |
Get viewport height .
gedi::Int32 gedi::SAM::GetMapWidth | ( | void | ) | [inline] |
Get map width in tiles.
gedi::Int32 gedi::SAM::GetMapHeight | ( | void | ) | [inline] |
Get map height in tiles .
gedi::Int32 gedi::SAM::GetBlkWidth | ( | void | ) | [inline] |
Get tile width in pixels.
gedi::Int32 gedi::SAM::GetBlkHeight | ( | void | ) | [inline] |
Get tile height in pixels.
void gedi::SAM::LoadImage | ( | LPSTR | lpszFilename | ) |
Load the tile image file.
lpszFilename | Bit map or targa file name. |
void gedi::SAM::SetMappy | ( | const BLKSTR | pBlkProps[], | |
const ANISTR | pAniProps[], | |||
const short | pMapProps[], | |||
const int | pAniSeqs[] | |||
) |
Set the Mappy properties from the text export file.
pBlkProps | Block properties which they give image tile numbers, etc. | |
pAniProps | Animation properites reference by <0 block indexes in pMapProps. | |
pMapProps | Layout of map 1D format: pMapProps[y*mapwidth+x] | |
pAniSeqs | Animation sequences referenced pAniProps. |
gedi::Bool32 gedi::SAM::Scroll | ( | gedi::Int32 | iXDelta, | |
gedi::Int32 | iYDelta | |||
) |
Scroll by pixel increment.
iXDelta | Increment +- in X direction. | |
iYDelta | Increment +- in Y direction. |
void gedi::SAM::ScrollBlock | ( | gedi::Int32 | iXDelta, | |
gedi::Int32 | iYDelta | |||
) |
Scroll by tile increment.
iXDelta | Increment +- in X direction. | |
iYDelta | Increment +- in Y direction. |
void gedi::SAM::SetDimensions | ( | gedi::Int32 | iMapBlkWidth, | |
gedi::Int32 | iMapBlkHeight, | |||
gedi::Int32 | iTileWidth, | |||
gedi::Int32 | iTileHeight | |||
) |
Set map dimensions.
Use this method if the default constructor invoked.
iMapBlkWidth | Map width in blocks (or tiles). | |
iMapBlkHeight | Map height in blocks (or tiles). | |
iTileWidth | Tile width in pixels. | |
iTileHeight | Tile height in pixels. |
void gedi::SAM::SetViewDimensions | ( | gedi::Int32 | iXViewWidth, | |
gedi::Int32 | iYViewHeight | |||
) |
Set the viewport dimensions.
iXViewWidth | X width (pixels). | |
iYViewHeight | Y height (pixels). |