GetMapBlockTransparent
Transparent = GetMapBlockTransparent(MapIndex, BlockIndex)
 
Parameters:

    MapIndex = The index of the map you wish to query
    BlockIndex = The index of the block you wish to query
Returns:

    Transparent = The transparent state of this block. -1 = Empty, 0 = Solid and 1='s Transparent
 

      The GetMapBlockTransparent function returns the transparent status block within a map. Blocks have three basic states, those being Empty, Transparent and Solid. These states are used mainly to help speed up he map Collision, Occlusion and rendering commands.


Transparent States


-1 = Block Is empty (no visible pixels within it)
0 = Block is Solid (no transparent pixels or maskcolour pixels)
1 = Block contains some transparent pixels.




FACTS:


* The transparent state of a block is calculated when blocks are being imported, for speed reasons, some import methods (Ie. where it requires getting block data from a video image) don't scan the blocks pixels to classify it, rather they will just tag it as being transparent.





Mini Tutorial:


The example creates a block image and a MAP, then displays the transparent status of each block graphic.


  
  
; clear the screen to black 0 = rgb(0,0,0)
  Cls RGB(0,0,0)
  
; Set some variables to hold the Width/Heigth and number
; of blocks this demo will use.
  BlockWidth     =20
  BlockHeight     =20
  NUmbOfBLocks=10
  
; Create a strip of circle blocks. Where every second one has
; a red backdrop.
  
  For lp=0 To NUmbOfBLocks
   ; calc the colour. (every second loop it'll fill the backdrop
   ; tile with a red colour. Making this block no transparent
     col=RGB(255,0,0)*(lp And 1)
     
   ; Fill this block with a box
     BoxC Xpos,0,Xpos+BlockWidth,BlockHeight,true,Col
     
   ; draw a randomly coloured ellipse on this block
     EllipseC xpos+(BlockWidth/2),Ypos+(BlockHEight/2),_
     BlockWidth/3,BlockHeight/3,trueRndRGB()
     
     Xpos=Xpos+BlockWidth
  Next
  
; Grab this strip of blocks (from the screen) as Image #1
  GetImage 1,0,0,Xpos,BlockHeight
  
; Clear the screen back to black
  Cls RGB(0,0,255)
  
; Create a Map
  MyMap=NewMap(1)
  
; Inport image #1 as blocks into this map
  MakeMapGFX MyMap,1,BlockWidth,BlockHeight,NUmbOfBLocks,0
  
; Set the coordinate to output the info about the blocks
  Xpos=200
  Ypos=100
  
; Loop through the blocks in this map
  For Blk=0 To GetMapBlockQuantity(myMap)
     
   ; Check if this block is transparent or not
     Transparent=GetMapBlockTransparent(MyMap,blk)
     
   ; Display the block index and the transparent status of this block
     Text xpos,ypos, "blk: ("+Digits$(blk,2)+") Transparent=("+Str$(transparent)+")"
     
   ; draw hhe block along side
     DrawMapBlk MyMap,blk,Xpos+250,ypos,Transparent
     
   ; bump the output y value
     ypos=ypos+BlockHeight+10
  Next
  
; refresh the screen and wait for the a key press
  Sync
  WaitKey
  
  



This example would output something like this. You'll have to cut and paste the demo to see it action.

  
  blk: (00) Transparent=(1)
  blk: (01) Transparent=(0)
  blk: (02) Transparent=(1)
  blk: (03) Transparent=(0)
  blk: (04) Transparent=(1)
  blk: (05) Transparent=(0)
  blk: (06) Transparent=(1)
  blk: (07) Transparent=(0)
  blk: (08) Transparent=(1)
  blk: (09) Transparent=(0)
  blk: (10) Transparent=(1)
  


 
Related Info: CreateMapGfx | GetMapBlockQuantity | GetMapBlocks | GetMapBlockStatus | LoadMapGfx | MakeMapGfx :
 


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