LevelTransparent
LevelTransparent MapIndex, LevelIndex, TransparentBlock
 
Parameters:

    MapIndex = The Index of the Map you wish to set a levels render mode
    LevelIndex = The index of the level you wish to set to transparent
    TransparentBlock = The Index of a totally transparent block to ignore.
Returns: NONE
 
     LevelTransparent sets a levels rendering mode to transparent. In transparent mode, the level tiles will be drawn using the previously defined block transparency colour. So any colour within the blocks, will be masked out and appear as transparent.

      Transparent mode also requires an extra parameter. This parameter is the index of a block that is known to be clear. Since we know this block is clear, then obviously it doesn't make sense to drawn a clear block. It's a waste of valuable processing time. Thus we screen this block out entirely, so basically DrawMap will ignore it.


FACTS:


      * Transparent mode rendering is a little slower than solid mode where all the blocks are present and have a few transparent pixels.

      * Transparent mode can be combined with animation mode.

      * Since PlayBASIC V1.64N each block has three transparent states, those being SOLID, partyly transparent and completely transparent. Which allows the transparent map rendering to do a better job at screening out blocks that don't need drawing.




Mini Tutorial:


      This example creates a maps level, and then draws the solid and transparent versions of this level at the mouse pointers current position, as if the level was a sprite.


  
  
  
; Set Width & Height variables of the Map tiles
  TileWidth=20
  Tileheight=20
  
  
; Create a map with provision for 5 levels
  MyMap=NewMap(5)
  
; Create some empty graphics blocks for MyMAP
  CreateMapGFX MyMap,TileWidth,TileHeight,10,RGB(0,0,0)
  Cls RGB(0,0,0)
  For lp=1 To 9
   ; draw a randomly coloured box
     BoxC 0,0,TileWidth/2,TileHeight/2,1,RndRGB()
   ; Copy the box image into MyMap
     GetMapBlk MyMap, lp, 0,0
  Next
  
  
; Create level 1
  CreateLevel MyMap,1,10,10
  
; Randomly Fill the level with Tiles
  For Ylp=0 To GetLevelWidth(myMap,1)
     For Xlp=0 To GetLevelWidth(myMap,1)
        PokeLevelTile MyMap,1,Xlp,Ylp,RndRange(1,9)
     Next
  Next
  
; Make a copy of level 1 as level 2
  CloneLevel MyMap,1,MyMap,2
  
; Set LEvel #1 as solid
  LevelSolid MyMap,1
  
; Set LEvel #2 as transparent
  LevelTransparent MyMap,2,0
  
  
; Start of Do/Loop
  Do
   ; clear the screen to black
     Cls RGB(255,20,30)
     
     
   ; Read the mouse position
     mx#=MouseX()
     my#=MouseY()
     
     
   ; Draw Level #1
     DrawMap MyMap,1,mx#-200,my#-100
     CenterText mx#-100,my#-120,">> SOLID MAP <<"
     
   ; DRaw the Level #2
     DrawMap MyMap,2,mx#+200,my#-100
     CenterText mx#+300,my#-120,">> TRANSPRENT MAP <<"
     
   ; Display the screen and loop back to the DO
     Sync
  Loop
  
  



This example would output.

  
  no Output
  

 
Related Info: CreateLevel | CreateMap | DrawMap | GetLevelDrawMode | LevelAnimated | LevelDrawMode | LevelSolid | LevelTransparentTile :
 


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