MakeMapGfx
MakeMapGfx MapIndex, ImageIndex, TileWidth, TileHeight, NumbOfTiles, TransparentColour, [Format=1]
 
Parameters:

    MapIndex = The Index Identifier of the Map you wish to assign this level to.
    ImageIndex = The index of the Image you wish to build this maps Tile Graphics from.
    TileWidth = The Width in pixels of the tiles
    TileHeight = The Height in pixels of the tiles
    NumbOfTiles = The number of tiles to grab from this image
    TransparentColour = The transparent colour (in RGB fromat) to use for these tiles.
    [Format=1] = The image format of graphical blocks (1=Video, 2= FX, 4 = AFX)
Returns: NONE
 

     MakeMapGfx will import any Image into a map as the maps graphical tiles. Maps store the tiles internally in a special format, so once the tiles have been imported from your image, the source image can be safely deleted.

      The tiles will be of whatever size (width and height) you specify. They are grabbed from the image starting from top left hand corner scanning across each line, until it reaches the bottom of the image. You can specify the number of tiles you wish to grab, which must be at least be one, and can be no larger than 1024 for Video formatted blocks (default) for 4096 or FX / AFX formatted blocks .

      During the block importation process, you'll need get to give the MakeMapGfx command the RGB value of the blocks transparent colour. This colour is used as the transparency mask when rendering levels that are set to 'transparent'. This is commonly used when various level are drawn over each to create parallax (multi layer) style effects. So setting this value incorrectly will no doubt result in your tiles not rendering with transparency.


      Block Formats:

1 = Video Memory
2 = FX
4 = AFX (Supports Alpha Channel)




FACTS:


      * Tiles are grabbed from left to right, starting from the top left hand corner of the source image and working down.

      * You can specfiy any number of tiles you like. The MakeMapGfx routine will only create/grab that amount. Regardless of the size of the image.

      * Each Map can only have 1024 video tiles, or 4096 in FX/AFX formats stored within them.

      * There's no limited upon the size(width/height) of the Tiles.

      * MakeMapGfx will automatically import any AFX image internally as an AFX map. Allow maps to support Alpha Channel. If you using Alpha channel, then set the Transparent Mask Colour to zero.




Block Map Tile Import Order Example:


      The MakeMapGfx imports your block graphics from your source picture, it starts in the top left corner and moves across the image. If it reaches the right hand edge, it moves down a row and starts scanning from the left again. It will repeat this process until it reaches the end of the image, or the max number of user defined blocks.

      The example picture bellow is 320 by 240 pixels and contains 16 blocks, which are 80 * 60 pixels per block. This means that there's only 4 blocks per row, making the block image square. The block image doesn't have to square though, It just is in this example.










Mini Tutorial:


      This example Creates a Map, then manually builds a tiled image, just so it can import it and finally build and display

  
  
; First We'll create a Map
  MyMap = NewMap(1)
  
  
; Next, we'll  maunally build a series of randomly coloured
; blocks in a row to the screen.  We'll then grab these blocks
; as an image, so we can import them into our Map above.
  
  
  TileWidth=32
  TileHeight=32
  Number_of_tiles = 5
  
; Loop through and draw a series of randomly coloured
; Boxes to the screen
  For lp=1 To Number_of_tiles
     xpos=lp*tileWidth
     BoxC Xpos,0,Xpos+TileWidth,TileHeight,1,RndRGB()
  Next
  
; Grab the box graphics that we've just drawn as image.
  TempImage=GetFreeImage()
  GetImage TempImage,0,0,xpos+TIleWidth,Tileheight
  
  
  
; So far we've created our Map and Manually created an
; image containing some coloured boxes. Now it's time to
; import this image into our Map.
  
; When we have tile graphics stored within an image, we
; import them using the MAPMAPGFX command.  This command
; requires the Map you wish to import theses tiles to,
; the Image to import, the Tile Width, the Tile Height,
; number of tiles to import and finally the transparent
; colour (if any) to use for these tiles.
  
; Import this image into our previously defined Map.
  
  MakeMapGFX MyMAP,TempImage,TileWidth,TileHeight,Number_Of_Tiles,RGB(0,0,0)
  
  
  
;   Now we have a Map that has a set of tiles ready for use
;  in it, so the next thing we need to is create a level.  This
;  is done with the CREATELEVEL command.  Which requires two
;  things, it needs the know within what MAP this level should
;  be created, and what Level Index it should for this level.
  
  
; Create level 1 in MyMAP, 100 tile across and 200 tiles down.
  CreateLevel MyMap,1100,200
  
  
  
;  We're just about ready now to start drawing, but first we need
; to fill the level with what tiles it should draw.  In this example,
; the following code will randomly fill the level.  Normally you
; would use a level editing program like PLAY MAPPER for such things.
; But your welcome to do it manually if you like.
  
  For Ylp=0 To GetLevelHeight(mymap,1)-1
     For Xlp=0 To (GetLevelWidth(MyMap,1)-1)
        PokeLevelTile MyMap,1,Xlp,ylp,Rnd(number_of_tiles)
     Next xlp
  Next ylp
  
; Draw the Level to the screen at Xpos 0 and Ypos 50
  DrawMap MyMap,1,0,50
  
; Show the user te screen and wait for a key to be pressed
  Sync
  WaitKey
  




 
Related Info: CreateMapGfx | LoadAfxImage | LoadMapGfx | PrepareFXmap :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com