|
This is the documentation for the SDLMappy class, designed for SDL (www.###).
SDLMappy handles .FMP files created by Mappy Win32 Editor, (C) Robin Burrows. The current official Mappy Homepage is: http://www.geocities.com/SiliconValley/Vista/7336/robmpy.htm, with mirrors at http://www.rbsite.freeserve.co.uk/robmpy.htm and (if all else fails) http://surf.to/mappy SDLMappy is based on original sources from Robin Burrows, was ported and modified for CDX by Ioannis Karagiorgos and then ported and modified for SDL by Regis Quercioli. Known problems:
Displaying maps in 8-bit modes is not supported! SetColorKey is not implemented in SDLMappy, the default ColorKey for transparency is the one of the first block (block n°0 - and this block must be blank). MapDrawFG is not implemented in SDLMappy, because I don't understand its purpose...
TutorialHere is a little code tutorial on how to use SDLMappy in your projects: InitializingFirst of all you have to create your SDLMappy object:SDLMappy * Map = new SDLMappy; Next, load your map: if( Map->LoadMap("Map.fmp" , 0 , 0 , 320 , 200 )
== -1 )
When the map loading fails, it returns -1. LoadMap wants to have the filename of the map, the x/y coordinates of the map on the screen (where drawing will start, upper-left hand corner -- usually 0,0) and the visible map dimensions (width/height). If you want a parallax surface, call if( Map->CreateParallax( "parallax.bmp" ) == SDL_FALSE
)
Unlike CDXMappy the parallax surface size don't need to be a multiple of the map block size (its dimensions can be totally indifferent) !!! If your Map is using animated tiles then you have to initialize the animations: Map->MapInitAnims( ); Thats all there has to be done for initialization. DrawingHere are the functions needed to draw the map.If you are using animated tiles, first call Map->MapUpdateAnims( ); Then, call Map->MapMoveTo( x , y ) to move the map at the desired pixel position. If you are using a parallax surface, you have to draw it first, for example: if( Map->DrawParallax( SDLSurface * Surface ) ==
-1 )
Map->MapDrawBG( SDLSurface * Surface ) draws the
background layer
Map Methodsint LoadMap (char * Filename , int x , int y , int Width , int Height); Loads the map with the path and name specified into memory so it can be used. This function must be used before calling other Mappy functions. void MapInitAnims (void); Resets animations to their initial values.
Increments animations. Generally used once during an update loop before drawing.
MapDrawBG draws the background layer without transparency, so it will completely overwrite the specified area. int MapDrawBGT (SDLSurface* s); MapDrawBGT draws the background layer with transparency. Any block whose tile is tile 0, or pixels of the transparent color in all blocks, won't overwrite be drawn. int MapChangeLayer (int layernumber); This changes to a different map layer, returns -1 if failed, or the new layer number (0 to 7) if successful. int MapGetTile (int x, int y); Returns the content of a block at position x,y. The x and y paramaters are the offset from the left and top of the map in BLOCKS, NOT pixels. BLKSTR * MapGetBlock (int x, int y); Returns a BLKSTR pointer, useful for collision detection and examining a block structure. Note: the x and y paramaters are the offset from the left and top of the map in BLOCKS, NOT pixels. Example: MapSetBlock (int x, int y, int strvalue); The x and y paramaters are the offset from the left and top of the map in BLOCKS, NOT pixels. If strvalue is positive, the cell is set to that block structure. If strvalue is negative the cell is set to that anim structure - 1 (ie if you want to put anim 3 in, strvalue would be -4). WORD GetMapBPP( void ); This call returns the color depth of the current map. WORD GetMapWidth( void ); This call returns the width of the map in pixels. WORD GetMapHeight( void ); This call returns the height of the map in pixels. WORD GetMapWidthInBlocks( void ); This call returns the width of the map in blocks. WORD GetMapHeightInBlocks( void ); This call returns the height of the map in blocks. WORD GetMapBlockWidth( void ); Thie call returns the width of one map block, in pixels. WORD GetMapBlockHeight( void ); Thie call returns the height of one map block, in pixels. void MapMoveTo( int x , int y ); This call moves the map output to offset x,y. It takes into account invalid coordinates, and will modify them accordingly so as to not scroll off the edges of the map and cause a crash. int MapGetXPosition( void ); This call returns the current X offset of the map, in pixels, from the upper-left hand corner. int MapGetYPosition( void ); This call returns the current Y offset of the map, in pixels, from the upper-left hand corner. int DrawParallax( CDXSurface * Surface ); This call draws the parallax surface on the selected surface. BOOL CreateParallax( void ); This call creates and load a parallax surface from bitmap file Filename
If you have problems with CDXMappy, please e-mail me
September 2000 , Regis
Quercioli
|